GNU bug report logs - #22933
M-x guix-edit fails gracelessly when passed an nonexistent package name

Previous Next

Package: guix;

Reported by: ludo <at> gnu.org (Ludovic Courtès)

Date: Mon, 7 Mar 2016 16:30:02 UTC

Severity: normal

Done: ludo <at> gnu.org (Ludovic Courtès)

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 22933 in the body.
You can then email your comments to 22933 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#22933; Package guix. (Mon, 07 Mar 2016 16:30:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to ludo <at> gnu.org (Ludovic Courtès):
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Mon, 07 Mar 2016 16:30:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: bug-guix <at> gnu.org
Cc: Alex Kost <alezost <at> gmail.com>
Subject: M-x guix-edit fails gracelessly when passed an nonexistent package
 name
Date: Mon, 07 Mar 2016 17:28:48 +0100
[Message part 1 (text/plain, inline)]
Currently M-x guix-edit fails badly (actually ‘guix-package-location’)
pwhen passed the name of a nonexistent package:

--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (error "Error in evaluating guile expression: ERROR: In procedure car:
ERROR: In procedure car: Wrong type (expecting pair): ()

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [3]> ")
  signal(error ("Error in evaluating guile expression: ERROR: In procedure car:\nERROR: In procedure car: Wrong type (expecting pair): ()\n\nEntering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.\nscheme@(guile-user) [3]> "))
  error("Error in evaluating guile expression: %s" "ERROR: In procedure car:\nERROR: In procedure car: Wrong type (expecting pair): ()\n\nEntering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.\nscheme@(guile-user) [3]> ")
  (if (geiser-eval--retort-error res) (error "Error in evaluating guile expression: %s" (geiser-eval--retort-output res)) (cdr (assq (quote result) res)))
  (let ((res (geiser-eval--send/wait (list (quote :eval) (list (quote :scm) str))))) (if (geiser-eval--retort-error res) (error "Error in evaluating guile expression: %s" (geiser-eval--retort-output res)) (cdr (assq (quote result) res))))
  (save-current-buffer (set-buffer (or repl (guix-geiser-repl))) (let ((res (geiser-eval--send/wait (list (quote :eval) (list (quote :scm) str))))) (if (geiser-eval--retort-error res) (error "Error in evaluating guile expression: %s" (geiser-eval--retort-output res)) (cdr (assq (quote result) res)))))
  guix-geiser-eval("(package-location-string \"foo\")" #<buffer *Guix Internal REPL*>)
  (car (guix-geiser-eval str repl))
  (replace-regexp-in-string "#t" "t" (car (guix-geiser-eval str repl)))
  (replace-regexp-in-string "#f\\|#<unspecified>" "nil" (replace-regexp-in-string "#t" "t" (car (guix-geiser-eval str repl))))
  (read (replace-regexp-in-string "#f\\|#<unspecified>" "nil" (replace-regexp-in-string "#t" "t" (car (guix-geiser-eval str repl)))))
  guix-geiser-eval-read("(package-location-string \"foo\")" #<buffer *Guix Internal REPL*>)
  guix-eval-read("(package-location-string \"foo\")")
  guix-package-location("foo")
  eval((guix-package-location "foo") nil)
  eval-expression((guix-package-location "foo") nil)
  call-interactively(eval-expression nil nil)
  command-execute(eval-expression)
--8<---------------cut here---------------end--------------->8---

I think this patch fixes it:

[Message part 2 (text/x-patch, inline)]
diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index 34da6ac..c5d5d75 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -954,10 +954,14 @@ GENERATIONS is a list of generation numbers."
 
 (define (package-location-string id-or-name)
   "Return a location string of a package with ID-OR-NAME."
-  (and-let* ((package  (or (package-by-id id-or-name)
-                           (first (packages-by-name id-or-name))))
-             (location (package-location package)))
-    (location->string location)))
+  (define package
+    (or (package-by-id id-or-name)
+        (match (packages-by-name id-or-name)
+          (() #f)
+          ((first . rest) first))))
+
+  (and package
+       (location->string (package-location package))))
 
 (define (package-source-derivation->store-path derivation)
   "Return a store path of the package source DERIVATION."
[Message part 3 (text/plain, inline)]
Thoughts?

Ludo’.

Information forwarded to bug-guix <at> gnu.org:
bug#22933; Package guix. (Mon, 07 Mar 2016 19:59:02 GMT) Full text and rfc822 format available.

Message #8 received at 22933 <at> debbugs.gnu.org (full text, mbox):

From: Mathieu Lirzin <mthl <at> gnu.org>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 22933 <at> debbugs.gnu.org, Alex Kost <alezost <at> gmail.com>
Subject: Re: bug#22933: M-x guix-edit fails gracelessly when passed an
 nonexistent package name
Date: Mon, 07 Mar 2016 20:58:15 +0100
ludo <at> gnu.org (Ludovic Courtès) writes:

> diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
> index 34da6ac..c5d5d75 100644
> --- a/emacs/guix-main.scm
> +++ b/emacs/guix-main.scm
> @@ -954,10 +954,14 @@ GENERATIONS is a list of generation numbers."
>  
>  (define (package-location-string id-or-name)
>    "Return a location string of a package with ID-OR-NAME."
> -  (and-let* ((package  (or (package-by-id id-or-name)
> -                           (first (packages-by-name id-or-name))))
> -             (location (package-location package)))
> -    (location->string location)))
> +  (define package
> +    (or (package-by-id id-or-name)
> +        (match (packages-by-name id-or-name)
> +          (() #f)
> +          ((first . rest) first))))
> +
> +  (and package
> +       (location->string (package-location package))))

Not related to the bug.  but it feels weird to use internal defines for
something else than a procedure.

what about using (not tested):

--8<---------------cut here---------------start------------->8---
  (and=> (or (package-by-id id-or-name)
             (match (packages-by-name id-or-name)
               (()        #f)
               ((pkg ..1) pkg)))
         (compose location->string package-location))
--8<---------------cut here---------------end--------------->8---

I know you love my 'pkg' identifier.  ;)

-- 
Mathieu Lirzin




Information forwarded to bug-guix <at> gnu.org:
bug#22933; Package guix. (Mon, 07 Mar 2016 21:05:01 GMT) Full text and rfc822 format available.

Message #11 received at 22933 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Mathieu Lirzin <mthl <at> gnu.org>
Cc: 22933 <at> debbugs.gnu.org, Alex Kost <alezost <at> gmail.com>
Subject: Re: bug#22933: M-x guix-edit fails gracelessly when passed an
 nonexistent package name
Date: Mon, 07 Mar 2016 22:03:49 +0100
Mathieu Lirzin <mthl <at> gnu.org> skribis:

> ludo <at> gnu.org (Ludovic Courtès) writes:
>
>> diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
>> index 34da6ac..c5d5d75 100644
>> --- a/emacs/guix-main.scm
>> +++ b/emacs/guix-main.scm
>> @@ -954,10 +954,14 @@ GENERATIONS is a list of generation numbers."
>>  
>>  (define (package-location-string id-or-name)
>>    "Return a location string of a package with ID-OR-NAME."
>> -  (and-let* ((package  (or (package-by-id id-or-name)
>> -                           (first (packages-by-name id-or-name))))
>> -             (location (package-location package)))
>> -    (location->string location)))
>> +  (define package
>> +    (or (package-by-id id-or-name)
>> +        (match (packages-by-name id-or-name)
>> +          (() #f)
>> +          ((first . rest) first))))
>> +
>> +  (and package
>> +       (location->string (package-location package))))
>
> Not related to the bug.  but it feels weird to use internal defines for
> something else than a procedure.

I don’t find it weird.  :-)

> what about using (not tested):
>
>   (and=> (or (package-by-id id-or-name)
>              (match (packages-by-name id-or-name)
>                (()        #f)
>                ((pkg ..1) pkg)))
>          (compose location->string package-location))

I like it too!

> I know you love my 'pkg' identifier.  ;)

No I don’t!  :-)

I think we should stick to one identifier style, which is to always use
full words (I’m often tempted to use abbreviations and I force myself
not to, as silly as I am!)

Ludo’.




Information forwarded to bug-guix <at> gnu.org:
bug#22933; Package guix. (Mon, 07 Mar 2016 23:02:01 GMT) Full text and rfc822 format available.

Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Alex Kost <alezost <at> gmail.com>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: Mathieu Lirzin <mthl <at> gnu.org>, bug-guix <at> gnu.org
Subject: Re: M-x guix-edit fails gracelessly when passed an nonexistent
 package name
Date: Tue, 08 Mar 2016 02:01:29 +0300
Ludovic Courtès (2016-03-07 19:28 +0300) wrote:

> Currently M-x guix-edit fails badly (actually ‘guix-package-location’)
> pwhen passed the name of a nonexistent package:
[...]
> I think this patch fixes it:
>
>
> diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
> index 34da6ac..c5d5d75 100644
> --- a/emacs/guix-main.scm
> +++ b/emacs/guix-main.scm
> @@ -954,10 +954,14 @@ GENERATIONS is a list of generation numbers."
>  
>  (define (package-location-string id-or-name)
>    "Return a location string of a package with ID-OR-NAME."
> -  (and-let* ((package  (or (package-by-id id-or-name)
> -                           (first (packages-by-name id-or-name))))
> -             (location (package-location package)))
> -    (location->string location)))
> +  (define package
> +    (or (package-by-id id-or-name)
> +        (match (packages-by-name id-or-name)
> +          (() #f)
> +          ((first . rest) first))))
> +
> +  (and package
> +       (location->string (package-location package))))
>  
>  (define (package-source-derivation->store-path derivation)
>    "Return a store path of the package source DERIVATION."
>
> Thoughts?

Great!  Thanks for fixing it!  Feel free (you or Mathieu) to push any of
your patches.

-- 
Alex




Information forwarded to bug-guix <at> gnu.org:
bug#22933; Package guix. (Mon, 07 Mar 2016 23:02:02 GMT) Full text and rfc822 format available.

Message #17 received at 22933 <at> debbugs.gnu.org (full text, mbox):

From: Alex Kost <alezost <at> gmail.com>
To: Mathieu Lirzin <mthl <at> gnu.org>
Cc: 22933 <at> debbugs.gnu.org, Ludovic Courtès <ludo <at> gnu.org>
Subject: Re: bug#22933: M-x guix-edit fails gracelessly when passed an
 nonexistent package name
Date: Tue, 08 Mar 2016 02:01:57 +0300
Mathieu Lirzin (2016-03-07 22:58 +0300) wrote:

> ludo <at> gnu.org (Ludovic Courtès) writes:
>
>> diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
>> index 34da6ac..c5d5d75 100644
>> --- a/emacs/guix-main.scm
>> +++ b/emacs/guix-main.scm
>> @@ -954,10 +954,14 @@ GENERATIONS is a list of generation numbers."
>>  
>>  (define (package-location-string id-or-name)
>>    "Return a location string of a package with ID-OR-NAME."
>> -  (and-let* ((package  (or (package-by-id id-or-name)
>> -                           (first (packages-by-name id-or-name))))
>> -             (location (package-location package)))
>> -    (location->string location)))
>> +  (define package
>> +    (or (package-by-id id-or-name)
>> +        (match (packages-by-name id-or-name)
>> +          (() #f)
>> +          ((first . rest) first))))
>> +
>> +  (and package
>> +       (location->string (package-location package))))
>
> Not related to the bug.  but it feels weird to use internal defines for
> something else than a procedure.

I have the same feeling.

> what about using (not tested):
>
>
>   (and=> (or (package-by-id id-or-name)
>              (match (packages-by-name id-or-name)
>                (()        #f)
>                ((pkg ..1) pkg)))
>          (compose location->string package-location))

I like this variant!

-- 
Alex




Information forwarded to bug-guix <at> gnu.org:
bug#22933; Package guix. (Mon, 07 Mar 2016 23:04:02 GMT) Full text and rfc822 format available.

Message #20 received at 22933 <at> debbugs.gnu.org (full text, mbox):

From: Alex Kost <alezost <at> gmail.com>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 22933 <at> debbugs.gnu.org, Mathieu Lirzin <mthl <at> gnu.org>
Subject: Re: bug#22933: M-x guix-edit fails gracelessly when passed an
 nonexistent package name
Date: Tue, 08 Mar 2016 02:03:56 +0300
Ludovic Courtès (2016-03-08 00:03 +0300) wrote:

[...]
>> what about using (not tested):
>>
>>   (and=> (or (package-by-id id-or-name)
>>              (match (packages-by-name id-or-name)
>>                (()        #f)
>>                ((pkg ..1) pkg)))
>>          (compose location->string package-location))
>
> I like it too!
>
>> I know you love my 'pkg' identifier.  ;)
>
> No I don’t!  :-)
>
> I think we should stick to one identifier style, which is to always use
> full words (I’m often tempted to use abbreviations and I force myself
> not to, as silly as I am!)

Good to know, I always thought that things like "pkg" or "drv" are OK in
a local scope.

-- 
Alex




Information forwarded to bug-guix <at> gnu.org:
bug#22933; Package guix. (Tue, 08 Mar 2016 10:14:01 GMT) Full text and rfc822 format available.

Message #23 received at 22933 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Alex Kost <alezost <at> gmail.com>
Cc: 22933 <at> debbugs.gnu.org, Mathieu Lirzin <mthl <at> gnu.org>
Subject: Re: bug#22933: M-x guix-edit fails gracelessly when passed an
 nonexistent package name
Date: Tue, 08 Mar 2016 11:13:36 +0100
Alex Kost <alezost <at> gmail.com> skribis:

> Ludovic Courtès (2016-03-08 00:03 +0300) wrote:
>
> [...]
>>> what about using (not tested):
>>>
>>>   (and=> (or (package-by-id id-or-name)
>>>              (match (packages-by-name id-or-name)
>>>                (()        #f)
>>>                ((pkg ..1) pkg)))
>>>          (compose location->string package-location))
>>
>> I like it too!
>>
>>> I know you love my 'pkg' identifier.  ;)
>>
>> No I don’t!  :-)
>>
>> I think we should stick to one identifier style, which is to always use
>> full words (I’m often tempted to use abbreviations and I force myself
>> not to, as silly as I am!)
>
> Good to know, I always thought that things like "pkg" or "drv" are OK in
> a local scope.

Well, ahem, ‘drv’ is an exception…

Otherwise I think the rationale of the “Naming” section at
<http://mumble.net/~campbell/scheme/style.txt> is a good one.

Ludo’.




Reply sent to ludo <at> gnu.org (Ludovic Courtès):
You have taken responsibility. (Tue, 08 Mar 2016 10:15:02 GMT) Full text and rfc822 format available.

Notification sent to ludo <at> gnu.org (Ludovic Courtès):
bug acknowledged by developer. (Tue, 08 Mar 2016 10:15:02 GMT) Full text and rfc822 format available.

Message #28 received at 22933-done <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Mathieu Lirzin <mthl <at> gnu.org>
Cc: 22933-done <at> debbugs.gnu.org, Alex Kost <alezost <at> gmail.com>
Subject: Re: bug#22933: M-x guix-edit fails gracelessly when passed an
 nonexistent package name
Date: Tue, 08 Mar 2016 11:14:33 +0100
Mathieu Lirzin <mthl <at> gnu.org> skribis:

> ludo <at> gnu.org (Ludovic Courtès) writes:
>
>> diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
>> index 34da6ac..c5d5d75 100644
>> --- a/emacs/guix-main.scm
>> +++ b/emacs/guix-main.scm
>> @@ -954,10 +954,14 @@ GENERATIONS is a list of generation numbers."
>>  
>>  (define (package-location-string id-or-name)
>>    "Return a location string of a package with ID-OR-NAME."
>> -  (and-let* ((package  (or (package-by-id id-or-name)
>> -                           (first (packages-by-name id-or-name))))
>> -             (location (package-location package)))
>> -    (location->string location)))
>> +  (define package
>> +    (or (package-by-id id-or-name)
>> +        (match (packages-by-name id-or-name)
>> +          (() #f)
>> +          ((first . rest) first))))
>> +
>> +  (and package
>> +       (location->string (package-location package))))
>
> Not related to the bug.  but it feels weird to use internal defines for
> something else than a procedure.
>
> what about using (not tested):
>
>   (and=> (or (package-by-id id-or-name)
>              (match (packages-by-name id-or-name)
>                (()        #f)
>                ((pkg ..1) pkg)))
>          (compose location->string package-location))
>
> I know you love my 'pkg' identifier.  ;)

Fixed along these lines in commit
16f4acbddbb38275a52554caf693017465586ac6.

(Note that ..1 matches a list of one or more element, not the first
element of a list.)

Ludo’.




Information forwarded to bug-guix <at> gnu.org:
bug#22933; Package guix. (Tue, 08 Mar 2016 14:39:01 GMT) Full text and rfc822 format available.

Message #31 received at 22933 <at> debbugs.gnu.org (full text, mbox):

From: Mathieu Lirzin <mthl <at> gnu.org>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 22933 <at> debbugs.gnu.org, Alex Kost <alezost <at> gmail.com>
Subject: Re: bug#22933: M-x guix-edit fails gracelessly when passed an
 nonexistent package name
Date: Tue, 08 Mar 2016 15:37:56 +0100
ludo <at> gnu.org (Ludovic Courtès) writes:

> Alex Kost <alezost <at> gmail.com> skribis:
>
>> Ludovic Courtès (2016-03-08 00:03 +0300) wrote:
>>>
>>> I think we should stick to one identifier style, which is to always use
>>> full words (I’m often tempted to use abbreviations and I force myself
>>> not to, as silly as I am!)
>>
>> Good to know, I always thought that things like "pkg" or "drv" are OK in
>> a local scope.
>
> Well, ahem, ‘drv’ is an exception…
>
> Otherwise I think the rationale of the “Naming” section at
> <http://mumble.net/~campbell/scheme/style.txt> is a good one.

I totally agree with the suggestions made in this section.  However
these conventions don't talk about "bound variables" which is IMO a
different context than the global name space.

I used to think that full words everywhere were a good thing, by
opposition of the unhelpful variables 'i' and 'x'.  Nonetheless, with
the experience (short I admit) I tend to think that an abbreviation is
still helpful for bound variables because it helps distinguishing them
from free variables.  It is even more true when the meaning of this
abbrevation is made explicit by the doc-string.

-- 
Mathieu Lirzin




Information forwarded to bug-guix <at> gnu.org:
bug#22933; Package guix. (Tue, 08 Mar 2016 14:54:01 GMT) Full text and rfc822 format available.

Message #34 received at 22933 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Mathieu Lirzin <mthl <at> gnu.org>
Cc: 22933 <at> debbugs.gnu.org, Alex Kost <alezost <at> gmail.com>
Subject: Re: bug#22933: M-x guix-edit fails gracelessly when passed an
 nonexistent package name
Date: Tue, 08 Mar 2016 15:53:21 +0100
Mathieu Lirzin <mthl <at> gnu.org> skribis:

> ludo <at> gnu.org (Ludovic Courtès) writes:
>
>> Alex Kost <alezost <at> gmail.com> skribis:
>>
>>> Ludovic Courtès (2016-03-08 00:03 +0300) wrote:
>>>>
>>>> I think we should stick to one identifier style, which is to always use
>>>> full words (I’m often tempted to use abbreviations and I force myself
>>>> not to, as silly as I am!)
>>>
>>> Good to know, I always thought that things like "pkg" or "drv" are OK in
>>> a local scope.
>>
>> Well, ahem, ‘drv’ is an exception…
>>
>> Otherwise I think the rationale of the “Naming” section at
>> <http://mumble.net/~campbell/scheme/style.txt> is a good one.
>
> I totally agree with the suggestions made in this section.  However
> these conventions don't talk about "bound variables" which is IMO a
> different context than the global name space.
>
> I used to think that full words everywhere were a good thing, by
> opposition of the unhelpful variables 'i' and 'x'.  Nonetheless, with
> the experience (short I admit) I tend to think that an abbreviation is
> still helpful for bound variables because it helps distinguishing them
> from free variables.  It is even more true when the meaning of this
> abbrevation is made explicit by the doc-string.

Yeah I was thinking along these lines at some point (as is apparent in
older parts of Guix ;-)), but my preference du jour is different.
Anyway, we’ll see next time such an issue comes up!

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 06 Apr 2016 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 21 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.