GNU bug report logs - #77703
[PATCH] guix-install.sh: Add to GITHUB_PATH in CI

Previous Next

Package: guix-patches;

Reported by: Rik Huijzer <rik.huijzer <at> gmail.com>

Date: Thu, 10 Apr 2025 14:09:01 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 77703 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#77703; Package guix-patches. (Thu, 10 Apr 2025 14:09:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Rik Huijzer <rik.huijzer <at> gmail.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Thu, 10 Apr 2025 14:09:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Rik Huijzer <rik.huijzer <at> gmail.com>
To: guix-patches <at> gnu.org
Cc: Rik Huijzer <rik.huijzer <at> gmail.com>
Subject: [PATCH] guix-install.sh: Add to GITHUB_PATH in CI
Date: Thu, 10 Apr 2025 08:55:57 +0200
I was trying to use guix inside a GitHub CI runner, and saw that this
code works:

```yaml
- uses: actions/checkout <at> v4
- run: sudo apt install guix
- run: echo "$HOME/.guix-profile/bin" >> $GITHUB_PATH
- run: guix install hello
- run: hello
```

But, I wonder if the line that adds `.guix-profile/bin` to the path can
be avoided. Without it the run fails. Normally, `apt install` also
modifies the PATH, so for me as a naive user it would be more intuitive
if the installer could do so here too.

For security reasons, GitHub has switched to the `$GITHUB_PATH`
environment variable in 2020
(https://stackoverflow.com/a/64831469/5056635). This PR suggests to add
it to the installer.

The code verifies that the CI env var is set to "true", which is always
true in GitHub Runners (see first entry in table at
https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables).
Then it also checks that GITHUB_PATH is set. I think it's a reasonable
assumption that if a system sets CI to true and GITHUB_PATH to
something, then it must be a GitHub Runner or at
least a system that looks like a GitHub Runner. But of course I could be
wrong.
---
 etc/guix-install.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index b5d833c..c6a2c54 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -752,6 +752,9 @@ export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
 # `guix pull` profile
 GUIX_PROFILE="$HOME/.config/guix/current"
 export PATH="$GUIX_PROFILE/bin${PATH:+:}$PATH"
+if [ "${CI}" == "true" ] && [ -n "${GITHUB_PATH}" ]; then
+  echo "$GUIX_PROFILE/bin" >> $GITHUB_PATH
+fi
 # Add to INFOPATH and MANPATH so the latest Guix documentation is available to
 # info and man readers.  When INFOPATH is unset, add a trailing colon so Emacs
 # searches 'Info-default-directory-list'.  When MANPATH is unset, add a

base-commit: 2934de1447f87b361608ef3a2a756b8a5d2f42e6
-- 
2.48.1





This bug report was last modified 2 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.