GNU bug report logs - #52691
[PATCH] git: Display a hint when CLONE* lacks permission.

Previous Next

Package: guix-patches;

Reported by: Tobias Geerinckx-Rice <me <at> tobias.gr>

Date: Tue, 21 Dec 2021 00:52:01 UTC

Severity: normal

Tags: patch

Full log


View this message in rfc822 format

From: zimoun <zimon.toutoune <at> gmail.com>
To: Tobias Geerinckx-Rice <me <at> tobias.gr>
Cc: 52691 <at> debbugs.gnu.org
Subject: [bug#52691] [PATCH] git: Display a hint when CLONE* lacks permission.
Date: Tue, 21 Dec 2021 15:42:07 +0100
[Message part 1 (text/plain, inline)]
Hi Tobias,

On mar., 21 déc. 2021 at 01:51, Tobias Geerinckx-Rice <me <at> tobias.gr> 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.

[clone.patch (text/x-diff, inline)]
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 \"<REPO-NAME>-<SHA1:7>\" where REPO-NAME is the name of
[Message part 3 (text/plain, inline)]

> +  #: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

This bug report was last modified 3 years and 235 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.