From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christopher Allan Webber Subject: diaper pattern lurking in ui.scm Date: Sat, 30 May 2015 12:37:36 -0500 Message-ID: <87a8wmt0s8.fsf@earlgrey.lan> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yykqq-0004Ql-58 for guix-devel@gnu.org; Sat, 30 May 2015 13:47:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yykqn-0001EH-05 for guix-devel@gnu.org; Sat, 30 May 2015 13:47:16 -0400 Received: from dustycloud.org ([50.116.34.160]:58290) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yykqm-0001E0-S6 for guix-devel@gnu.org; Sat, 30 May 2015 13:47:12 -0400 Received: from earlgrey.lan (localhost [127.0.0.1]) by dustycloud.org (Postfix) with ESMTPS id 9499726623 for ; Sat, 30 May 2015 13:47:11 -0400 (EDT) List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel I was working on a new package and found that I was very surprised that suddenly guix told me that "guix package" did not exist: cwebber@earlgrey:~/devel/guix$ guix package --help guix: package: command not found Try `guix --help' for more information. Whaaaa? So I dug into the source and found that in ui.scm there's this: (define (run-guix-command command . args) "Run COMMAND with the given ARGS. Report an error when COMMAND is not found." (define module (catch 'misc-error (lambda () (resolve-interface `(guix scripts ,command))) (lambda - (format (current-error-port) (_ "guix: ~a: command not found~%") command) (show-guix-usage)))) (let ((command-main (module-ref module (symbol-append 'guix- command)))) (parameterize ((program-name command)) (apply command-main args)))) That catch of 'misc-error was the problem that was hiding the relevant exception. I removed the "catch" and got guix to raise the real error. I had a real, actual problem with my package... I had done this: (source (origin (method url-fetch) (uri (string-append "http://download.gna.org/guile-dbi/guile-dbi-" version ".tar.gz")) (sha256 (base32 "3545ec6b589eaa601eb1ed275c00be0cc9ba08204a252415b205f1befce7d64a")))) Oops, I had just copied and pasted `sha256sum guile-dbi-2.1.5.tar.gz' output into the sexp structure I borrowed from another package. So the error that was *really* being thrown was: In guix/packages.scm: 182: 4 [# #] In guix/base32.scm: 260: 3 [base32-string-unfold-right # ...] In unknown file: ?: 2 [string-fold-right # ...] In guix/base32.scm: 261: 1 [# #\e 5] In unknown file: ?: 0 [scm-error misc-error #f "~A ~S" ("invalid base32 character" #\e) #f] ERROR: In procedure scm-error: ERROR: invalid base32 character #\e Aha, of course! That wasn't a base32 sha256 after all. No wonder! Unfortunately, instead of getting this useful error that could have helped me figure out my mistake above, the catch-all exception handling hid my real problem from view. I'm afraid we've fallen victim to the Diaper Pattern here: http://mike.pirnat.com/2009/05/09/the-diaper-pattern-stinks/ I think that a more explicit exception should be being thrown and caught in ui.scm. I could generate a patch, but I don't know what exception it's expecting might be raised. In other words, (error) considered harmful, use (throw 'specific-key) instead :) - Chris