Hi, John Kehayias <[email protected]> skribis:
> From 57cdc3a8f9c6451aaf17f1fafae0bcf29faeea03 Mon Sep 17 00:00:00 2001 > From: John Kehayias <[email protected]> > Date: Thu, 5 Jan 2023 16:06:19 -0500 > Subject: [PATCH] * environment: Fix '--emulate-fhs' option overriding $PATH. > > Fixes <https://issues.guix.gnu.org/60566> where even if "--preserve='^PATH$'" > was passed to 'guix shell' it would be replaced by just the FHS directories > when '--emulate-fhs' was also set. > > * gnu/scripts/environment.scm (launch-environment): Add the FHS directories to > $PATH rather than overriding $PATH completely. > --- > guix/scripts/environment.scm | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm > index c7fd8fd340..20fa5850c4 100644 > --- a/guix/scripts/environment.scm > +++ b/guix/scripts/environment.scm > @@ -475,10 +475,11 @@ (define* (launch-environment command profile manifest > (catch 'system-error > (lambda () > (when emulate-fhs? > - ;; When running in a container with EMULATE-FHS?, override $PATH > + ;; When running in a container with EMULATE-FHS?, augment $PATH > ;; (optional, but to better match FHS expectations), and generate > ;; /etc/ld.so.cache. > - (setenv "PATH" "/bin:/usr/bin:/sbin:/usr/sbin") > + (setenv "PATH" (string-append "/bin:/usr/bin:/sbin:/usr/sbin:" > + (getenv "PATH"))) To be safe, you need to account for (getenv "PATH") returning #f, and not add a trailing colon in that case. Other than that, I agree this is a valid change because that would be consistent with: --8<---------------cut here---------------start------------->8--- $ PATH=/foo $(type -P guix) shell -E ^PATH$ -C coreutils -- env |grep ^PATH PATH=/gnu/store/pfl0lyqbs557khv7rw90bzp24qp2lqsn-profile/bin:/foo --8<---------------cut here---------------end--------------->8--- Perhaps you can add a line to test it in ‘tests/guix-environment-container.sh’? Thanks, Ludo’.
