all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#52691] [PATCH] git: Display a hint when CLONE* lacks permission.
@ 2021-12-21  0:51 Tobias Geerinckx-Rice via Guix-patches via
  2021-12-21 14:42 ` zimoun
  0 siblings, 1 reply; 4+ messages in thread
From: Tobias Geerinckx-Rice via Guix-patches via @ 2021-12-21  0:51 UTC (permalink / raw)
  To: 52691

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
  $

* guix/git.scm (clone*): Print DIRECTORY as a hint on EPERM.

Reported by karrq on #guix.
---
 guix/git.scm | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/guix/git.scm b/guix/git.scm
index dc2ca1be84..1b322be0fe 100644
--- a/guix/git.scm
+++ b/guix/git.scm
@@ -35,6 +35,7 @@ (define-module (guix git)
   #:use-module (guix gexp)
   #:use-module (guix sets)
   #:use-module ((guix diagnostics) #:select (leave warning))
+  #:use-module (guix ui)
   #:use-module (guix progress)
   #:autoload   (guix swh) (swh-download commit-id?)
   #:use-module (rnrs bytevectors)
@@ -200,8 +201,16 @@ (define (clone* url directory)
       (clone url directory
              (make-clone-options
               #:fetch-options (make-default-fetch-options))))
-    (lambda _
-      (false-if-exception (rmdir directory)))))
+    (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)))))
 
 (define (url+commit->name url sha1)
   "Return the string \"<REPO-NAME>-<SHA1:7>\" where REPO-NAME is the name of
-- 
2.34.0





^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-21 15:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-21  0:51 [bug#52691] [PATCH] git: Display a hint when CLONE* lacks permission Tobias Geerinckx-Rice via Guix-patches via
2021-12-21 14:42 ` zimoun
2021-12-21 14:56   ` Tobias Geerinckx-Rice via Guix-patches via
2021-12-21 15:12     ` zimoun

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.