help-guix
[Top][All Lists]
Advanced

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

Re: Replacing python venv - environment or profile?


From: Maxim Cournoyer
Subject: Re: Replacing python venv - environment or profile?
Date: Sun, 29 Nov 2020 15:34:34 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

Hi Phil,

Phil <phil@beadling.co.uk> writes:

> Hi all,
>
> Apologies this is a bit longer than I anticipated, but I wanted to record
> all the steps I'd taken to explain my reasoning - in case it's wrong!
>
> I'm new the Guix and considering adopting it as an expansion to my
> current use of Python virtual environments in development and
> production, to include other non-Python packages too.
>
> The potential of the software is very exciting!
>
> I've read the manual/cookbook and I get the gist of the tool.  One thing
> I'm getting a bit stuck on is the appropriate use of environment vs
> profile; different sources give slightly different takes on the theme, and I
> want to make sure my use is correct from the get-go.

It seems you've done your homework :-).

> I'll be using Guix on a foreign OS, I suspect the answers might be
> slightly different if I was able to adopt the Guix System OS, but for
> now I can't.
>

[...]

> I'm keen to avoid accidentally calling anything in the foreign OS,
> something the 'guix environment' command gives me, but obviously the foreign
> OS will serve as a fallback given the above PATH construction under a sourced
> profile.  So if my profile doesn't have python installed, but it is part
> of the foreign OS, I would silently pick that up, which would be bad.
>
>
> As per 4.1.1 in the cookbook I can avoid setting other profiles using:
>
> $ env -i $(which bash) --login --noprofile --norc
> $ export GUIX_PROFILE=/home/ubuntu/dev/test-profile
> $ . $GUIX_PROFILE/etc/profile
>
> But the foreign OS variables remain:
>
> $ echo $PATH
> /home/ubuntu/dev/test-profile/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
> $ 

I could reproduce on a foreign distro but not on Guix System:

--8<---------------cut here---------------start------------->8---
$ env -i $(which bash) -c 'echo $PATH'
/no-such-path
--8<---------------cut here---------------end--------------->8---

It appears this is caused by the foreign Bash, which hard-codes a
default value for PATH
(/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin in your
case).

The Bash package on Guix (you can go to its definition using 'guix edit
bash') has the following compilation flags:

  (let* ((cppflags (string-join '("-DDEFAULT_PATH_VALUE='\"/no-such-path\"'"
                                  "-DSTANDARD_UTILS_PATH='\"/no-such-path\"'"
                                  "-DNON_INTERACTIVE_LOGIN_SHELLS"
                                  "-DSSH_SOURCE_BASHRC")
                                " "))

This is where that non-existing (/no-such-path) value comes from.

As a workaround, you could use Bash from Guix after installing it with 'guix 
install bash'.

HTH!

Thanks,

Maxim



reply via email to

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