Subject: Re: bug#32456: Guile failed to call package-derivation without pre-inst-env

From: [email-masked] (Ludovic Courtès)
Date: Tue, 21 Aug 2018 12:05:38 +0200

Hi,

Oleg Pykhalov <[email-masked]> skribis:

> natsu@magnolia ~/src/guix$ for path in $(printenv GUILE_LOAD_PATH | tr ':' '\n'); do echo -e "\n"; env GUILE_LOAD_PATH=$path pr
> intenv GUILE_LOAD_PATH; env GUILE_LOAD_PATH=$path guile -c '(use-modules (guix) (guix ui) (guix store)) (format #t "~s~%" (pack
> age-derivation (open-connection) (@@ (gnu packages base) hello)))'; done
>
>
> /home/natsu/.guix-profile/share/guile/site/2.2
> Backtrace:
> In guix/packages.scm:
>    923:16 19 (expand-input #<build-daemon 256.97 20fdaf0> #<package…> …)
>    878:14 18 (cache! #<weak-table 6/113> #<package [email-masked].…> …)
> In unknown file:
>           17 (_ #<procedure thunk ()> #<procedure list _> #<undefined>)
> In guix/packages.scm:
>   1202:22 16 (thunk)
>   1135:25 15 (bag->derivation #<build-daemon 256.97 20fdaf0> #<<bag…> …)
> In srfi/srfi-1.scm:
>    592:29 14 (map1 (("source" #<origin "mirror://cpan/src/5.0/p…>) …))
>    592:17 13 (map1 (("make" #<package [email-masked] gnu/pack…>) …))
> In guix/packages.scm:
>    923:16 12 (expand-input #<build-daemon 256.97 20fdaf0> #<package…> …)
>    878:14 11 (cache! #<weak-table 6/113> #<package [email-masked]…> …)
> In unknown file:
>           10 (_ #<procedure thunk ()> #<procedure list _> #<undefined>)
> In guix/packages.scm:
>   1202:22  9 (thunk)
> In guix/derivations.scm:
>   1242:24  8 (build-expression->derivation #<build-daemon 256.97 20…> …)
>   1004:18  7 (imported-files #<build-daemon 256.97 20fdaf0> ((. #) …) …)
> In srfi/srfi-1.scm:
>    592:29  6 (map1 (("guix/build/gnu-build-system.scm" . "/home/…") …))
>    592:29  5 (map1 (("guix/build/utils.scm" . "/home/natsu/.guix…") …))
>    592:29  4 (map1 (("guix/build/gremlin.scm" . "/home/natsu/.gu…") …))
>    592:17  3 (map1 (("guix/elf.scm" . "/home/natsu/.guix-profile/s…")))
> In guix/derivations.scm:
>   1007:31  2 (_ _)
> In guix/store.scm:
>    948:24  1 (_ #<build-daemon 256.97 20fdaf0> "elf.scm" #f "sha256" …)
>    928:31  0 (add-to-store #<build-daemon 256.97 20fdaf0> _ #f "sha…" …)
>
> guix/store.scm:928:31: In procedure add-to-store:
> Throw to key `srfi-34' with args `(#<condition &nix-protocol-error [message: "regular file expected" status: 1] 3539000>)'.

The problem here is that
~/.guix-profile/share/guile/site/2.2/guix/elf.scm is a symlink.  When
doing an ‘add-to-store’ RPC with #:recursive? #f, we pass that file
name, but the daemon rejects it because it’s not a regular file (it’s a
symlink; see nix-daemon.cc:416.)

I don’t understand the purpose of this check in nix-daemon.cc; I think
it’s useless.  However, removing it alone doesn’t solve the problem for
clients talking to old daemons.  So we’d need ‘add-to-store’ to resolve
symlinks when it’s talking to an old daemon.

However, I don’t understand why guix/elf.scm is a symlink in your
profile.  First that means you installed the ‘guix’ package in your
profile, which is not recommended (better have it in the ‘guix
pull’-managed profile.)  Second, that also means that two guix/
subdirectories were merged into one by ‘union-build’, which is
surprising: presumably only ‘guix’ provides such a subdirectory.
What do these commands report:

  ls -l ~/.guix-profile/share/guile/site/2.2/guix
  ls -l $(readlink ~/.guix-profile/share/guile/site/2.2/guix)

?

Thanks,
Ludo’.