unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Chris Marusich <cmmarusich@gmail.com>
Cc: guix-devel@gnu.org
Subject: Re: Mysterious error while refactoring guix/scripts/system.scm
Date: Mon, 29 Aug 2016 17:53:03 +0200	[thread overview]
Message-ID: <87k2ezzi5c.fsf@gnu.org> (raw)
In-Reply-To: <8737md3x5a.fsf@gmail.com> (Chris Marusich's message of "Wed, 10 Aug 2016 00:23:29 -0700")

Hi Chris, and sorry for the delay!

Chris Marusich <cmmarusich@gmail.com> skribis:

> Backtrace:
> In ice-9/boot-9.scm:
>  157: 15 [catch #t #<catch-closure 26304a0> ...]
> In unknown file:
>    ?: 14 [apply-smob/1 #<catch-closure 26304a0>]
> In ice-9/boot-9.scm:
>   63: 13 [call-with-prompt prompt0 ...]
> In ice-9/eval.scm:
>  432: 12 [eval # #]
> In ice-9/boot-9.scm:
> 2401: 11 [save-module-excursion #<procedure 264f940 at ice-9/boot-9.scm:4045:3 ()>]
> 4050: 10 [#<procedure 264f940 at ice-9/boot-9.scm:4045:3 ()>]
> 1724: 9 [%start-stack load-stack ...]
> 1729: 8 [#<procedure 2668ea0 ()>]
> In unknown file:
>    ?: 7 [primitive-load "/root/guix/scripts/guix"]
> In guix/ui.scm:
> 1209: 6 [run-guix-command system "list-generations"]
> In ice-9/boot-9.scm:
>  157: 5 [catch srfi-34 #<procedure 52af180 at guix/ui.scm:425:2 ()> ...]
>  157: 4 [catch system-error ...]
> In guix/scripts/system.scm:
>  884: 3 [#<procedure 52ae750 at guix/scripts/system.scm:876:2 ()>]
>  818: 2 [process-command list-generations () ...]
> In guix/store.scm:
> 1182: 1 [run-with-store # ...]
> In unknown file:
>    ?: 0 [#<unspecified> #<build-daemon 256.15 52b8e80>]
>
> ERROR: In procedure #<unspecified>:
> ERROR: Wrong type to apply: #<unspecified>

This means that we’re trying to invoke #<unspecified>, but
#<unspecified> is not a procedure.

Note that this is from within ‘run-to-store’, which is the procedure to
“run” a monadic value.  So in effect, what happened is equivalent to:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> ,use(guix monads)
scheme@(guile-user)> ,use(guix store)
scheme@(guile-user)> (with-store s
		       (run-with-store s *unspecified*))
ERROR: In procedure #<unspecified>:
ERROR: Wrong type to apply: #<unspecified>
--8<---------------cut here---------------end--------------->8---

The bug here is in fact a type error: ‘run-with-store’ expect a monadic
value, but what we have here is a regular value.

To “fix” it, we need:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (with-store s
		       (run-with-store s
			 (with-monad %store-monad (return *unspecified*))))
--8<---------------cut here---------------end--------------->8---

… where ‘return’ procedure a monadic value from a normal value.

In your case, ‘list-generations’ is not a monadic procedure (a procedure
that returns a monadic value), so in this patch:

  (run-with-store store
    …
    (list-generations))

… triggers this very type error.

I imagine this may be more than you wanted to learn.  ;-)
Monads in a dynamically typed setting are kinda annoying because of
this.

>  (define (process-command command args opts)
>    "Process COMMAND, one of the 'guix system' sub-commands.  ARGS is its
>  argument list and OPTS is the option alist."
> -  (case command
> -    ((list-generations)
> -     ;; List generations.  No need to connect to the daemon, etc.
> -     (let ((pattern (match args
> -                      (() "")
> -                      ((pattern) pattern)
> -                      (x (leave (_ "wrong number of arguments~%"))))))
> -       (list-generations pattern)))
> -    (else
> -     (process-action command args opts))))
> +  (with-store store
> +    (set-build-options-from-command-line store opts)
> +
> +    (run-with-store store
> +      (mbegin %store-monad
> +        (set-guile-for-build (default-guile))
> +        (case command
> +          ((list-generations)
> +           (let ((pattern (match args
> +                            (() "")
> +                            ((pattern) pattern)
> +                            (x (leave (_ "wrong number of arguments~%"))))))
> +             (list-generations pattern)))
> +          (else
> +           (process-action command args opts))))
> +      #:system (assoc-ref opts 'system))))

As the comment above suggests, the idea here was to avoid connecting to
the daemon for operations that do not need it, such as
‘list-generations’.  I think we should preserve this property.

Thanks for your work!  I’m sorry this is more painful than I thought.
:-/

Ludo’.

  reply	other threads:[~2016-08-29 15:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-04  6:20 Mysterious error while refactoring guix/scripts/system.scm Chris Marusich
2016-08-04  7:56 ` Andy Wingo
2016-08-10  7:23   ` Chris Marusich
2016-08-29 15:53     ` Ludovic Courtès [this message]
2016-09-24 19:54       ` Chris Marusich
2016-09-30 20:36         ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k2ezzi5c.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=cmmarusich@gmail.com \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).