From patchwork Tue Dec 21 14:42:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Tournier X-Patchwork-Id: 35519 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 2BA0827BBEA; Tue, 21 Dec 2021 14:57:11 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id A4CAE27BBE9 for ; Tue, 21 Dec 2021 14:57:10 +0000 (GMT) Received: from localhost ([::1]:52714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzgZh-0004gE-Sn for patchwork@mira.cbaines.net; Tue, 21 Dec 2021 09:57:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36518) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzgM2-0002IW-88 for guix-patches@gnu.org; Tue, 21 Dec 2021 09:43:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:41273) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mzgM1-0003k3-T1 for guix-patches@gnu.org; Tue, 21 Dec 2021 09:43:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mzgM1-0006Aj-I9 for guix-patches@gnu.org; Tue, 21 Dec 2021 09:43:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#52691] [PATCH] git: Display a hint when CLONE* lacks permission. Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 21 Dec 2021 14:43:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52691 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Tobias Geerinckx-Rice Cc: 52691@debbugs.gnu.org Received: via spool by 52691-submit@debbugs.gnu.org id=B52691.164009774423666 (code B ref 52691); Tue, 21 Dec 2021 14:43:01 +0000 Received: (at 52691) by debbugs.gnu.org; 21 Dec 2021 14:42:24 +0000 Received: from localhost ([127.0.0.1]:52819 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mzgLP-00069e-Pi for submit@debbugs.gnu.org; Tue, 21 Dec 2021 09:42:24 -0500 Received: from mail-wr1-f46.google.com ([209.85.221.46]:39671) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mzgLM-00069N-UB for 52691@debbugs.gnu.org; Tue, 21 Dec 2021 09:42:22 -0500 Received: by mail-wr1-f46.google.com with SMTP id s1so22004487wra.6 for <52691@debbugs.gnu.org>; Tue, 21 Dec 2021 06:42:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=mNV5dXlQznQYPKOnPa+I12L5J7a34/r9/fL+JtsTYGA=; b=exBuM/BX9kk53K14suvHgSOcb/KBXrWFxJFEyR2O167PQPl98PIgQcUxjc6WZI9S7k y1HH5CPUxUqU+2BRP4vVwbhM9HJiIiUweJQt4bgIKE8YZlecu8j9HEnUCSDQ9q+9H6oX KveC8BrVRULdyNdMMs7OmmIgul65PINh7CSDz2ibGpNxLGTx1zNnMnN7CPf6g0+re0Yc KMbUVr0XfTbNg3Qcj3Zlewykms+y4lADAKb2xdbz9jVUz2xqZL6+malaPtEW0Qfx/qEg E3LBZgzcbI7b1y4VCyaypFnioLP9xSj4aHMiKhXM+E/z04weaYWIz+ls4oNR3qWGZFo6 yuaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=mNV5dXlQznQYPKOnPa+I12L5J7a34/r9/fL+JtsTYGA=; b=eYKfFLuVGmkbsUulU3irntJ17Ja3aY6QCPB7pHr0OgJmU3R5A3o5K3lKcxzgLGDODt dQWC3+9EBhkxXR5S6EW8aydN6Hr8tEqRQnNKAUzUQTRSz/olbfyQgFJhljC237LoXtMf xM8d/q1d8HmWVbInyNZwiHRUVfU3tFL9jRkVkE8veKow6FpvxEdYuDzyk5D40uvoewPb /imNFs1ebeOTl5LH5cbkqA9sMinbgqql86VqIaBnr4RXYyaOVpeALwH9wJXKGdqTIcOV CFnaEfkGhbwSg6rsxcw9DEn5PeItdd6QGmYyXDEp3Cc/6fk3jmW8KU4HMO6LrwHIsfXl oU2Q== X-Gm-Message-State: AOAM5307GvSuhs+AnNi057DvfK3ZRnUvVbXEyP+kRUfApXbJ8G+/qDsq gZjcmLK9Ko+NYIX7gH0EaMaKPxW9bfY= X-Google-Smtp-Source: ABdhPJxDt82aY0xnfWF7RY+aW8RKx2Ta5kxi9jLtvP0eqDCfzc1fs7biPGSnDyGuJC4dq678gIaTbg== X-Received: by 2002:a05:6000:120e:: with SMTP id e14mr3000304wrx.392.1640097734924; Tue, 21 Dec 2021 06:42:14 -0800 (PST) Received: from jack-Precision-7820-Tower ([193.48.40.117]) by smtp.gmail.com with ESMTPSA id a22sm2565118wme.19.2021.12.21.06.42.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 06:42:14 -0800 (PST) From: zimoun References: <20211221005102.17638-1-me@tobias.gr> Date: Tue, 21 Dec 2021 15:42:07 +0100 In-Reply-To: <20211221005102.17638-1-me@tobias.gr> (Tobias Geerinckx-Rice's message of "Tue, 21 Dec 2021 01:51:02 +0100") Message-ID: <86y24exbnk.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hi Tobias, On mar., 21 déc. 2021 at 01:51, Tobias Geerinckx-Rice wrote: > Without this, it's not obvious where users should even start looking: > > $ guix pull > Updating channel 'guix' from Git repository at URL... > guix pull: error: mkdir: Permission denied Instead of hint, I propose this patch which displays: --8<---------------cut here---------------start------------->8--- Updating channel 'guix' from Git repository at 'https://git.savannah.gnu.org/git/guix.git'... guix pull: error: mkdir: Permission non accordée /home/sitour/.cache/guix/checkouts/pjmkglp4t7znuugeurpurzikxq3tnlaywmisyr27shj7apsnalwq --8<---------------cut here---------------end--------------->8--- Somehow, the URL is already reported and the patch exposes the hidden ’directory’ variable whatever the error could be. > + #:use-module (guix ui) I think that less UI is outside guix/scripts/ and easy maintenance we have. Ideally, G_ should only be under guix/scripts/. Last, if my proposal does not fit, from this snippet, --8<---------------cut here---------------start------------->8--- + (lambda args + (false-if-exception (rmdir directory)) + ;; Compensate for unixy errors, e.g., ‘error: mkdir: Permission denied’. + ;; XXX This displays the hint before the error. After would be nicer. + ;; XXX So would a generic mechanism for dealing with such errors. + (match args + ((system-error _ _ _ EPERM) + (display-hint (format #f (G_ "can you create and write to ~a?") + directory))) + (_ #f))))) --8<---------------cut here---------------end--------------->8--- the ’match’ can be avoided --8<---------------cut here---------------start------------->8--- (lambda (key subr message args . rest) (false-if-exception (rmdir directory)) ;; Compensate for unixy errors, e.g., ‘error: mkdir: Permission denied’. ;; XXX This displays the hint before the error. After would be nicer. ;; XXX So would a generic mechanism for dealing with such errors. (when (= EPERM (car rest)) (display-hint (format #f (G_ "can you create and write to ~a?") directory)))) --8<---------------cut here---------------end--------------->8--- Or someting along these lines. :-) Cheers, simon diff --git a/guix/git.scm b/guix/git.scm index dc2ca1be84..e2285f5f55 100644 --- a/guix/git.scm +++ b/guix/git.scm @@ -200,8 +200,12 @@ (define (clone* url directory) (clone url directory (make-clone-options #:fetch-options (make-default-fetch-options)))) - (lambda _ - (false-if-exception (rmdir directory))))) + (lambda (key subr fmt args . rest) + (let ((message (match args + ((reason tail ...) + (list (string-append reason " " directory)))))) + (false-if-exception (rmdir directory)) + (apply throw key subr fmt message rest))))) (define (url+commit->name url sha1) "Return the string \"-\" where REPO-NAME is the name of