GNU bug report logs - #77878
[PATCH] pre-inst-env: Issue a warning if nor run within a guix shell.

Previous Next

Package: guix-patches;

Reported by: nomike <nomike <at> nomike.com>

Date: Thu, 17 Apr 2025 21:38:03 UTC

Severity: normal

Tags: patch

Full log


View this message in rfc822 format

From: nomike <nomike <at> nomike.com>
To: 77878 <at> debbugs.gnu.org
Cc: nomike <nomike <at> nomike.com>
Subject: [bug#77878] [PATCH] pre-inst-env: Issue a warning if nor run within a guix shell.
Date: Thu, 17 Apr 2025 23:36:29 +0200
Change-Id: I9f212b3c665b7d8ac653c44eeafe6fc41da5b8ff
---
When running ./pre-inst-env on a foreign distro not within a guix shell, weird things happen.

```plaintext
$ ./pre-inst-env guix lint nano
guix: lint: command not found
hint: Did you mean `lint'?

Try `guix --help' for more information.
```

This patch changes pre-inst-env to issue a warning in that case, which could be especially helpful for newbies.
Perhaps a pointer to the right place in the documentation would be helpful here as well.

 build-aux/pre-inst-env.in | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/build-aux/pre-inst-env.in b/build-aux/pre-inst-env.in
index cd90a06cbc..6081d7aaa5 100644
--- a/build-aux/pre-inst-env.in
+++ b/build-aux/pre-inst-env.in
@@ -24,6 +24,11 @@
 # Run COMMAND in a pre-installation environment.  Typical use is
 # "./pre-inst-env guix build hello".
 
+# Check whether we currently are in a guix shell and issue a warning if we're not
+if [ -z "$GUIX_ENVIRONMENT" ]; then
+    echo "\e[1mWarning:\e[0m you are not in a guix shell. This may lead to unexpected results." >&2
+fi
+
 # By default we may end up with absolute directory names that contain '..',
 # which get into $GUILE_LOAD_PATH, leading to '..' in the module file names
 # recorded by Guile.  To avoid that, make sure we get a real absolute
-- 
2.49.0





This bug report was last modified 58 days ago.

Previous Next


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