From: John Kehayias via Bug reports for GNU Guix <bug-guix@gnu.org>
To: jman <jman@city17.xyz>
Cc: "Ludovic Courtès" <ludo@gnu.org>, 60566@debbugs.gnu.org
Subject: bug#60566: [PATCH] environment: Fix '--emulate-fhs' option overriding $PATH.
Date: Thu, 05 Jan 2023 21:19:48 +0000 [thread overview]
Message-ID: <874jt4k7bl.fsf@protonmail.com> (raw)
In-Reply-To: <875ydl29rj.fsf@city17.xyz>
[-- Attachment #1: Type: text/plain, Size: 1263 bytes --]
On Wed, Jan 04, 2023 at 11:33 PM, jman wrote:
> Hello,
>
> When emulating a FHS I observe that env vars seems to be not preserved. Example,
> the following command will not preserve $PATH:
>
> guix shell --container --emulate-fhs --preserve='^PATH$'
>
> When creating a container *without* emulating a FHS, env vars are available,
> example:
>
> guix shell --container --preserve='^PATH$'
>
> Pastebin log of a sample of this behaviour:
> https://paste.sr.ht/~jman/65e7f96c445504e11f55595b237280e0c1e3ad34
>
> ref: https://lists.gnu.org/archive/html/help-guix/2023-01/msg00002.html
>
> Thanks for an opinion on this
Thanks for reporting, I can confirm this behavior.
Here is a patch for this where the FHS directories are added to the
current value of $PATH. I believe this should in general be fine since
this is the last step before actually calling the command given to 'guix
shell' and thus $PATH has been set or preserved as needed already.
CC'ing Ludo as most familiar with this code. Anything we should be aware
of here? This change to $PATH in the first place wasn't strictly needed
('guix shell' already has the profile bin directory) but I thought made
sense to make it look most like FHS.
Thanks!
John
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-environment-Fix-emulate-fhs-option-overriding-PATH.patch --]
[-- Type: text/x-patch; name=0001-environment-Fix-emulate-fhs-option-overriding-PATH.patch, Size: 1587 bytes --]
From 57cdc3a8f9c6451aaf17f1fafae0bcf29faeea03 Mon Sep 17 00:00:00 2001
From: John Kehayias <john.kehayias@protonmail.com>
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")))
(invoke "ldconfig" "-X"))
(apply execlp program program args))
(lambda _
--
2.38.1
next prev parent reply other threads:[~2023-01-05 21:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-04 22:33 bug#60566: guix container with FHS emulation and env vars jman via Bug reports for GNU Guix
2023-01-05 21:19 ` John Kehayias via Bug reports for GNU Guix [this message]
2023-01-06 23:03 ` bug#60566: [PATCH] environment: Fix '--emulate-fhs' option overriding $PATH Ludovic Courtès
2023-01-13 21:44 ` John Kehayias via Bug reports for GNU Guix
2023-01-14 14:41 ` Ludovic Courtès
2023-01-15 23:05 ` John Kehayias via Bug reports for GNU Guix
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=874jt4k7bl.fsf@protonmail.com \
--to=bug-guix@gnu.org \
--cc=60566@debbugs.gnu.org \
--cc=jman@city17.xyz \
--cc=john.kehayias@protonmail.com \
--cc=ludo@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).