From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 11 15:23:22 2022 Received: (at submit) by debbugs.gnu.org; 11 Jun 2022 19:23:22 +0000 Received: from localhost ([127.0.0.1]:54060 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o06hd-0005AO-Tl for submit@debbugs.gnu.org; Sat, 11 Jun 2022 15:23:22 -0400 Received: from lists.gnu.org ([209.51.188.17]:47312) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o06hZ-0005AE-Uz for submit@debbugs.gnu.org; Sat, 11 Jun 2022 15:23:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o06hZ-0000F3-9C for bug-guix@gnu.org; Sat, 11 Jun 2022 15:23:17 -0400 Received: from michel.telenet-ops.be ([2a02:1800:110:4::f00:18]:40474) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o06hP-0000HJ-Fx for bug-guix@gnu.org; Sat, 11 Jun 2022 15:23:09 -0400 Received: from [172.20.10.9] ([213.119.188.102]) by michel.telenet-ops.be with bizsmtp id hvP22700M2CzlQd06vP33d; Sat, 11 Jun 2022 21:23:03 +0200 Message-ID: <5d91e5d62cc52af3a0893c34e46b7a42c4eea8c5.camel@telenet.be> Subject: run-guix-command catches too much, causing bogus "guix: ~a: command not found" error messages From: Maxime Devos To: bug-guix@gnu.org Date: Sat, 11 Jun 2022 21:22:56 +0200 Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-5yAl8T/KaXXFjfUpM8OP" User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22; t=1654975383; bh=fzt3e5FgdQhZU/9NSzVQvcKnO+4JRHpFD3FH5Nv+xq4=; h=Subject:From:To:Date; b=SSD6uEuifi4Pj05/esXzx4BjvcLXBj5jn/G5RlupqZZYIwjMR122T3VHMoF+vz54D M2Be2rhjCVL/nhF+5wHVQNzR8ahfidJP4yChntkylS0CfBWN61wERrIrnfm7wQxI8I nnaLJ+NsQaKDLCX1VthB10zMl08kkegMICLsW6nymOLc3DMi76oIJ2w1AUb0jOr51a S0ZeJOMYJyJLi8Rm704BIhMnx5njoJ2N2mhO4zTGeW1TEgsIIzDiKNrC0XsKH6OHqS 9hwSC31HNhtaoTven/hLVt+2rR2b0jw0hNVV1RT+OW0wSdRQP+bsnBG9dDoXowYaXL Brhxf21XPWnYg== Received-SPF: pass client-ip=2a02:1800:110:4::f00:18; envelope-from=maximedevos@telenet.be; helo=michel.telenet-ops.be X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=-5yAl8T/KaXXFjfUpM8OP Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, Someone on IRC (#guix) didn't have guile-json in their environment or something. When they did "./pre-inst-env guix lint", that failed with "guix: lint: command not found", which is bogus, since guix/scripts/lint.{scm,go} existed. The issue was tracked down to the 'run-guix-command' procedure, in particular the definition of module: (define module ;; Check if there is a matching extension. (match [something that returns #false in this situation] (#f (catch 'misc-error (lambda () (resolve-interface `(guix scripts ,command))) (lambda _ (let ((hint (command-hint command (commands)))) (format (current-error-port) (G_ "guix: ~a: command not found~%") command) (when hint (display-hint (format #f (G_ "Did you mean @code{~a}?") hint))) (show-guix-usage))))) (file [a case that doesn't apply here]))) To test the hypothesis that exception handling went wrong, the exception handling was modified to do some 'pk': (catch 'misc-error (lambda () (resolve-interface `(guix scripts ,command))) (lambda _ (pk 'what _) ; <---- new line! [old code])) which resulted in: ;;; (what (misc-error #f "no code for module ~S" ((json)) #f)) My proposal to avoid the wrong error message is (untested): ;; #:ensure #false: don't create an empty module when not found ;; (why is #:ensure #true even the default?). (let ((module (resolve-module `(guix scripts ,command) #:ensure #false))) (if module (module-public-interface module) ; script module was found [display hints & error message & guix-usage etc.])) (Reported-By: foobarxyz on #guix) Greetings, Maxime --=-5yAl8T/KaXXFjfUpM8OP Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYqTrkBccbWF4aW1lZGV2 b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7htCAQDum2CrWDI/xIhamM2PkVPXNaQM eQgbhr5hoYnDTzHvJAD/cVRCjakoFcGUluGJ8cnQrt6D4gS/ns6aUOSjj6UdUAo= =5N7b -----END PGP SIGNATURE----- --=-5yAl8T/KaXXFjfUpM8OP--