From: Lars-Dominik Braun <ldb@leibniz-psychology.org>
To: 43034@debbugs.gnu.org
Subject: [bug#43034] [PATCH] environment: Set USER and LOGNAME in container
Date: Tue, 25 Aug 2020 10:58:24 +0200 [thread overview]
Message-ID: <20200825085824.GA3150@zpidnp36> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 510 bytes --]
Hi,
I noticed `guix environment -C` lacks the two environment variable USER and
LOGNAME, which are part of %precious-variables (i.e. not cleared), but not
explicitly set when using a container. Some programs, in my case RStudio (see
https://github.com/leibniz-psychology/psychnotebook-app-rstudio/commit/3e15b9b173b8a9d2a7f55743ecba24e54b77ffad),
expect these to be set and can’t function properly without. Thus, the attached
patch exports them. This works with and without `-u`.
Cheers,
Lars
[-- Attachment #1.2: 0001-environment-Set-USER-and-LOGNAME-in-container.patch --]
[-- Type: text/x-diff, Size: 1510 bytes --]
From 516fecf81c980a020906533cd5135c6a7603a0a1 Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <ldb@leibniz-psychology.org>
Date: Tue, 25 Aug 2020 10:52:21 +0200
Subject: [PATCH] environment: Set USER and LOGNAME in container
* guix/scripts/environment.scm (launch-environment/container): Set
username environment variables.
---
guix/scripts/environment.scm | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index b8979cac19..1fb3505307 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -477,6 +477,7 @@ WHILE-LIST."
(group-entry (gid 65534) ;the overflow GID
(name "overflow"))))
(home-dir (password-entry-directory passwd))
+ (logname (password-entry-name passwd))
(environ (filter (match-lambda
((variable . value)
(find (cut regexp-exec <> variable)
@@ -528,6 +529,10 @@ WHILE-LIST."
;; The same variables as in Nix's 'build.cc'.
'("TMPDIR" "TEMPDIR" "TMP" "TEMP"))
+ ;; Some programs expect USER and/or LOGNAME to be set.
+ (setenv "LOGNAME" logname)
+ (setenv "USER" logname)
+
;; Create a dummy home directory.
(mkdir-p home-dir)
(setenv "HOME" home-dir)
--
2.26.2
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
next reply other threads:[~2020-08-25 8:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-25 8:58 Lars-Dominik Braun [this message]
2020-08-30 21:54 ` bug#43034: [PATCH] environment: Set USER and LOGNAME in container 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=20200825085824.GA3150@zpidnp36 \
--to=ldb@leibniz-psychology.org \
--cc=43034@debbugs.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).