From patchwork Tue Dec 21 00:51:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Geerinckx-Rice X-Patchwork-Id: 35491 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 26B2327BBE9; Tue, 21 Dec 2021 00:52:22 +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_INVALID, DKIM_SIGNED,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 B5FC727BBEA for ; Tue, 21 Dec 2021 00:52:21 +0000 (GMT) Received: from localhost ([::1]:53654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzTO8-0006Nl-V2 for patchwork@mira.cbaines.net; Mon, 20 Dec 2021 19:52:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzTO0-0006NE-H6 for guix-patches@gnu.org; Mon, 20 Dec 2021 19:52:12 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:40232) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mzTNq-0007zC-0S for guix-patches@gnu.org; Mon, 20 Dec 2021 19:52:11 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mzTNp-00041T-S4 for guix-patches@gnu.org; Mon, 20 Dec 2021 19:52:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#52691] [PATCH] git: Display a hint when CLONE* lacks permission. Resent-From: Tobias Geerinckx-Rice Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 21 Dec 2021 00:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 52691 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 52691@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.164004786915404 (code B ref -1); Tue, 21 Dec 2021 00:52:01 +0000 Received: (at submit) by debbugs.gnu.org; 21 Dec 2021 00:51:09 +0000 Received: from localhost ([127.0.0.1]:51778 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mzTMz-00040O-Ec for submit@debbugs.gnu.org; Mon, 20 Dec 2021 19:51:09 -0500 Received: from lists.gnu.org ([209.51.188.17]:55292) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mzTMx-00040H-Ns for submit@debbugs.gnu.org; Mon, 20 Dec 2021 19:51:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzTMx-0006Ff-DW for guix-patches@gnu.org; Mon, 20 Dec 2021 19:51:07 -0500 Received: from [2a02:c205:2020:6054::1] (port=35672 helo=tobias.gr) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzTMs-0007oA-QK for guix-patches@gnu.org; Mon, 20 Dec 2021 19:51:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=2018; bh=J+2op2u2pv4sf iwgYF08A37jVhwrdJ0kJcngs1kBD5c=; h=date:subject:to:from; d=tobias.gr; b=Q7bXDzrSrzvzSo3yuBPeb3iGFOJqeZuW9l/yRe7Or7AWaNKBBc/VKltFKYbwGCyRSHPz wgotB5Lzj2JavxgcqENj2wEemz7cKoFbIQsw0snJ+Gkm0ehU3Hgu9Ykai/Ikaq1N8EGNO+ LMRJlgTmjztcDoVB9S8XDmbcUSE4WP4WUgG4+qdNosVyo/4l77z0S4AhDWvBLEv4bdAdzo +4eg+ZKM6VyggvPGaTcxBpg+cGzXinQ6EbpcA3CJfywTnhU0cAqNDsyFyOhWq/oT5XgM+F 9W9XgAlhQYTwS9HoQfaiUukFsTBwp/vypGY31Bhj0GCgFYweFbL1nmcTZBNZQv1Q== Received: by submission.tobias.gr (OpenSMTPD) with ESMTPSA id 734c98ad (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for ; Tue, 21 Dec 2021 00:50:56 +0000 (UTC) Date: Tue, 21 Dec 2021 01:51:02 +0100 Message-Id: <20211221005102.17638-1-me@tobias.gr> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a02:c205:2020:6054::1 (failed) Received-SPF: pass client-ip=2a02:c205:2020:6054::1; envelope-from=me@tobias.gr; helo=tobias.gr X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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" Reply-to: Tobias Geerinckx-Rice X-ACL-Warn: , Tobias Geerinckx-Rice via Guix-patches X-Patchwork-Original-From: Tobias Geerinckx-Rice via Guix-patches via From: Tobias Geerinckx-Rice X-getmail-retrieved-from-mailbox: Patches 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 \"-\" where REPO-NAME is the name of