From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id cGboJ0zrwWG9dgAAgWs5BA (envelope-from ) for ; Tue, 21 Dec 2021 15:57:16 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id SNu9I0zrwWETeQAA1q6Kng (envelope-from ) for ; Tue, 21 Dec 2021 14:57:16 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 3BE331D7AA for ; Tue, 21 Dec 2021 15:57:16 +0100 (CET) Received: from localhost ([::1]:52714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzgZn-0004gE-Cx for larch@yhetil.org; Tue, 21 Dec 2021 09:57:15 -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 Content-Type: multipart/mixed; boundary="=-=-=" 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1640098636; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=mNV5dXlQznQYPKOnPa+I12L5J7a34/r9/fL+JtsTYGA=; b=vDoPMGxZLCoHyT1LutX8cwPbcugwU14FDZHoa8Yn5080gG2PbJ9ZyoJudN5+gnmMTMsAfj qMHdxk/i7+SrO75B8YRSi032MgOQ96/2FUW6FOvBDztm5OFvo7x0kpq/UzhzSJ9SL6o8FO 2+05NCVDrgBAxvBa0kisUPjmFbzk8WVBWEulHaZX3/c2+7AmB4Xmq2Eqrqv1lZj3UxZ7e2 JxXKUa5vKglNiA51knNgfWeO44s6DfqDzaZLfO8WlFgzphSChihgvVV5id9jN0m2G72cwa ZBRhaNPOceFM9T2dLWiojRRZ+TOCXmmfb7uKddeIydvhPH8+H4D8Y0ROh1VGcQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1640098636; a=rsa-sha256; cv=none; b=GSslhmPDacNMC2LjAkyyuT9FmR86BMXZMK09MAVzr1r7G9H5aaHIf5tbcuxZL62VbGsvyO nhM9HOSVNXBrBajKzHANHJUedMnBV3TqCfhR7hIB5PAcQQS7y6nQSiXBcRCSBddCSpbDLn O2UI9x3712efWeSRieXVY3Ni8T/af8lXtRHOLOZGkDdhNAjp3nLR5vrbyIXY+DkuwQF0wm HbJOEEFQFDr5jw+LJf+X7Ns0dyq0B57wFTndzOXeIvInUz6fNb+/iBV8jOVsg1do2ABxys oS3+HOuB0PvucT0sERcxBhwJQJNIr2v6QJGNXD0/NdEavulEWjrOgJbpDcnMJg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b="exBuM/BX"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.93 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b="exBuM/BX"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 3BE331D7AA X-Spam-Score: -2.93 X-Migadu-Scanner: scn0.migadu.com X-TUID: QXp4+9t7PtkR --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Tobias, On mar., 21 d=C3=A9c. 2021 at 01:51, Tobias Geerinckx-Rice w= rote: > 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.or= g/git/guix.git'... guix pull: error: mkdir: Permission non accord=C3=A9e /home/sitour/.cache/g= uix/checkouts/pjmkglp4t7znuugeurpurzikxq3tnlaywmisyr27shj7apsnalwq --8<---------------cut here---------------end--------------->8--- Somehow, the URL is already reported and the patch exposes the hidden =E2=80=99directory=E2=80=99 variable whatever the error could be. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=clone.patch Content-Description: clone.patch 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 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > + #: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., =E2=80=98error: mkdir: Permiss= ion denied=E2=80=99. + ;; XXX This displays the hint before the error. After would be nice= r. + ;; 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 =E2=80=99match=E2=80=99 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., =E2=80=98error: mkdir: Permissi= on denied=E2=80=99. ;; XXX This displays the hint before the error. After would be nicer. ;; XXX So would a generic mechanism for dealing with such errors. (when (=3D 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 --=-=-=--