Subject: Re: When logged as user, GUILE_LOAD_COMPILED_PATH points to the system cache instead of the user cache

From: Liliana Marie Prikler <[email-masked]>
Date: Wed, 22 Dec 2021 08:57:06 +0100

Hi Denis,

Am Mittwoch, dem 22.12.2021 um 01:16 +0100 schrieb Denis 'GNUtoo'
Carikli:
> [A]s user GUILE_LOAD_COMPILED_PATH is somehow exported to system
> paths:
> > [gnutoo@primary_laptop ~]$ echo $GUILE_LOAD_COMPILED_PATH
> > /run/current-system/profile/lib/guile/3.0/site-ccache:/run/current-
> > system/profile/share/guile/site/3.0
> 
> So if I instead set it to the right paths it works again:
> > [gnutoo@primary_laptop guix]$ export
> > GUILE_LOAD_COMPILED_PATH="/home/gnutoo/.config/guix/current/lib/guile
> > /3.0/site-
> > ccache:/home/gnutoo/.config/guix/current/share/guile/site/3.0"
> > [gnutoo@primary_laptop guix]$ guix package -i hello
> > The following package will be upgraded:
> >    hello (dependencies or package changed)
> > 
> > nothing to be done
> 
> 'GUILE_LOAD_COMPILED_PATH="" guix package -i hello' also works.
> 
> In my case the issue is that having
> '/run/current-system/profile/lib/guile/3.0/site-ccache' in
> GUILE_LOAD_COMPILED_PATH makes it fail:
> > [gnutoo@primary_laptop guix]$ export
> > GUILE_LOAD_COMPILED_PATH=/run/current-
> > system/profile/lib/guile/3.0/site-ccache
> > [gnutoo@primary_laptop guix]$ guix package -i hello Backtrace:
> > In ice-9/boot-9.scm:
> >    222:29 19 (map1 (((gnu packages gnupg)) ((gnu packages golang))
> > …))
> [...]
> 
> And apparently it fails just because it is in the path:
> > [gnutoo@primary_laptop guix]$ export
> > GUILE_LOAD_COMPILED_PATH="/home/gnutoo/.config/guix/current/lib/guile
> > /3.0/site-
> > ccache:/home/gnutoo/.config/guix/current/share/guile/site/3.0:/run/cu
> > rrent-system/profile/lib/guile/3.0/site-ccache"
> > [gnutoo@primary_laptop guix]$ guix package -i hello Backtrace:
> > In ice-9/boot-9.scm:
> >    222:29 19 (map1 (((gnu packages gnupg)) ((gnu packages golang))
> > …))
> [...]
> 
> This behavior probably happens becuase the system guix wasn't updated
> with guix system reconfigure for some time, and that the user relies on
> the system guile cache.
> 
> And as I understand from #guix on liberachat, I'm supposed to be able
> to not keep my user profile and my guix system in sync.
This is only true to some extent.  The local guix command still relies
on things in the system, such as the guix daemon itself, so you ought
to keep it up to date.

GUILE_LOAD_PATH does not point to the system cache "instead of" the
user cache, it gets expanded via profiles as everything else.  Since
Guix has a system-wide installation of guile-3.0-latest, the guile
paths get set.  You should probably install Guile locally instead of
system-wide if you plan on having the two diverge farther.

> Would the solution to that be to correctly export
> GUILE_LOAD_COMPILED_PATH in  ~/.guix-profile/etc/profile like it is
> done in the patch I attached (with an extra small modification in the
> commit message to mention the bug report)?
No.  The Guix command as built by `guix pull' sets its own load path,
but respects system paths too.  You can check by spawning a REPL:

scheme@(guix-user)> %load-path
$1 = ("/gnu/store/yi47s6iy3glwzimy3nch1h7c9hjzmyw8-guix-module-
union/share/guile/site/3.0"
"/gnu/store/3h3jn0745ngd87zp83k5smwhykxvdfgf-guile-
3.0.7/share/guile/3.0" "/gnu/store/3h3jn0745ngd87zp83k5smwhykxvdfgf-
guile-3.0.7/share/guile/3.0"
"/gnu/store/3h3jn0745ngd87zp83k5smwhykxvdfgf-guile-
3.0.7/share/guile/site/3.0"
"/gnu/store/3h3jn0745ngd87zp83k5smwhykxvdfgf-guile-
3.0.7/share/guile/site" "/gnu/store/3h3jn0745ngd87zp83k5smwhykxvdfgf-
guile-3.0.7/share/guile" "/run/current-
system/profile/share/guile/site/3.0")

> Other commits fixing bugs in that same profile mentioned bug reports,
> so I assume that it's simplier to discuss the bug in a bug report
> than directly sending a patch to fix the issue.
> 
> Note that I also didn't test the patch yet but I did test that export
> command.
For the record, guile has been a part of the system profile since
%base-packages were first defined, so if your load paths break, there
is probably a larger issue at hand.  In this particular case, your
local guix profile ought to shadow anything that's in /run/current-
system, so I don't really get how the ABI match is triggered.  Perhaps
you might want to debug that in a REPL.

Cheers