bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#35942: guix install: environment variable message is very confusing


From: Ludovic Courtès
Subject: bug#35942: guix install: environment variable message is very confusing
Date: Fri, 31 May 2019 23:19:55 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)

Hi!

Ricardo Wurmus <address@hidden> skribis:

> Ludovic Courtès <address@hidden> writes:

[...]

>>> <https://lists.gnu.org/archive/html/guix-devel/2019-02/msg00362.html>
>>
>> I don’t think we reached a conclusion back then.  I’m fine with Robert’s
>> suggestion, but do people think it will really help?
>>
>> Others were in favor of dropping this message altogether, which I think
>> wouldn’t be a good idea: how would people discover about search path
>> handling?
>
> I was in favour of *replacing* the message with the suggestion to run
>
>    export GUIX_PROFILE=/this/profile
>    source $GUIX_PROFILE/etc/profile
>
> because it usually does the right thing.
>
> It looks less overwhelming than the individual list of environment
> variables.  I’ve seen a lot of people who added all of these variables
> to their bashrc (or bash_profile if they talked to me before), which is
> not what we want to encourage.
>
> We can also hint at “guix package --search-paths” to see a full list of
> environment variables for people who want to set them manually right
> here and now.

Sounds good to me.

How about the following patch?

It does produce a slightly verbose message, but I don’t think we can do
much better (we could save one line by not mentioning ‘--search-paths’.)

Thanks for getting the ball rolling.  :-)

Ludo’.

diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 06e4cf5b9c..5751123525 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -57,7 +57,6 @@
   #:export (build-and-use-profile
             delete-generations
             delete-matching-generations
-            display-search-paths
             guix-package
 
             (%options . %package-options)
@@ -169,8 +168,7 @@ hooks\" run when building the profile."
                               "~a packages in profile~%"
                               count)
                        count)
-               (display-search-paths entries (list profile)
-                                     #:kind 'prefix)))
+               (display-search-path-hint entries profile)))
 
         (warn-about-disk-space profile))))))
 
@@ -289,17 +287,23 @@ symlinks like 'canonicalize-path' would do."
       file
       (string-append (getcwd) "/" file)))
 
-(define* (display-search-paths entries profiles
-                               #:key (kind 'exact))
-  "Display the search path environment variables that may need to be set for
-ENTRIES, a list of manifest entries, in the context of PROFILE."
-  (let* ((profiles (map (compose user-friendly-profile absolutize)
-                        profiles))
-         (settings (search-path-environment-variables entries profiles
-                                                      #:kind kind)))
+(define (display-search-path-hint entries profile)
+  "Display a hint on how to set environment variables to use ENTRIES, a list
+of manifest entries, in the context of PROFILE."
+  (let* ((profile  (user-friendly-profile (absolutize profile)))
+         (settings (search-path-environment-variables entries (list profile)
+                                                      #:kind 'prefix)))
     (unless (null? settings)
-      (format #t (G_ "The following environment variable definitions may be 
needed:~%"))
-      (format #t "~{   ~a~%~}" settings))))
+      (display-hint (format #f (G_ "Consider setting the necessary environment
+variables by running:
+
address@hidden
+GUIX_PROFILE=\"~a\"
+. \"$GUIX_PROFILE/etc/profile\"
address@hidden example
+
+Alternately, see @command{guix package --search-paths -p ~s}.")
+                            profile profile)))))
 
 
 ;;;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]