unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Tobias Geerinckx-Rice via Guix-patches via <guix-patches@gnu.org>
To: 52691@debbugs.gnu.org
Subject: [bug#52691] [PATCH] git: Display a hint when CLONE* lacks permission.
Date: Tue, 21 Dec 2021 01:51:02 +0100	[thread overview]
Message-ID: <20211221005102.17638-1-me@tobias.gr> (raw)

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





             reply	other threads:[~2021-12-21  0:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-21  0:51 Tobias Geerinckx-Rice via Guix-patches via [this message]
2021-12-21 14:42 ` [bug#52691] [PATCH] git: Display a hint when CLONE* lacks permission zimoun
2021-12-21 14:56   ` Tobias Geerinckx-Rice via Guix-patches via
2021-12-21 15:12     ` zimoun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211221005102.17638-1-me@tobias.gr \
    --to=guix-patches@gnu.org \
    --cc=52691@debbugs.gnu.org \
    --cc=me@tobias.gr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).