You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pixi shell has different PATH than pixi run when PATH gets modified in rc files #246
He @pavelzw,
That would be bad, i'm not able to reproduce it locally:
~/test
➜ which python3
/usr/bin/python3
~/test
➜ pixi r which python3
/home/rarts/test/.pixi/env/bin/python3
~/test
➜ pixi s
~/test via 🅒 test
➜ which python3
~/test/.pixi/env/bin/python3
Also my in pixi's environment paths are equal:
~/test
➜ echo$PATH
/home/rarts/.local/bin:/home/rarts/bin:/usr/condabin:/usr/lib64/ccache:/home/rarts/.cargo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/var/lib/snapd/snap/bin:/home/rarts/.local/share/JetBrains/Toolbox/scripts:/home/rarts/.local/share/JetBrains/Toolbox/scripts:/home/rarts/.pixi/bin
~/test
➜ pixi r echo\$PATH
/home/rarts/test/.pixi/env/bin:/home/rarts/.local/bin:/home/rarts/bin:/usr/condabin:/usr/lib64/ccache:/home/rarts/.cargo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/var/lib/snapd/snap/bin:/home/rarts/.local/share/JetBrains/Toolbox/scripts:/home/rarts/.local/share/JetBrains/Toolbox/scripts:/home/rarts/.pixi/bin
~/test
➜ pixi s
~/test via 🅒 test
➜ echo$PATH
/home/rarts/test/.pixi/env/bin:/home/rarts/.local/bin:/home/rarts/bin:/usr/condabin:/usr/lib64/ccache:/home/rarts/.cargo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/var/lib/snapd/snap/bin:/home/rarts/.local/share/JetBrains/Toolbox/scripts:/home/rarts/.local/share/JetBrains/Toolbox/scripts:/home/rarts/.pixi/bin
When I compare both PATHs, I can see that pixi run has .pixi/env/bin at the top while pixi shell doesn't.
$ pixi run echo\$PATH
/private/tmp/aaaa/.pixi/env/bin
/Users/pavel/.local/share/pnpm
/Users/pavel/.pixi/bin
/Users/pavel/.local/bin
/opt/homebrew/bin
/opt/homebrew/sbin
/opt/local/bin
[...]
$ pixi shell
$ echo$PATH
/Users/pavel/.local/share/pnpm
/Users/pavel/.pixi/bin
/Users/pavel/.local/bin
/opt/homebrew/bin
/opt/homebrew/sbin
# from here it is the same
/private/tmp/aaaa/.pixi/env/bin
/Users/pavel/.local/share/pnpm
/Users/pavel/.pixi/bin
/Users/pavel/.local/bin
/opt/homebrew/bin
/opt/homebrew/sbin
/opt/local/bin
[...]
We can see that in pixi shell it adds the additional PATH stuff that I explicitly added in my .zshrc while it doesn't do that in pixi run.
Can you reproduce the issue with this?
$ docker run --rm -it ubuntu
$ apt update && apt install -y curl
# use the x86_64 version when not on ARM
$ curl -Ls https://github.com/prefix-dev/pixi/releases/download/v0.0.8/pixi-aarch64-unknown-linux-musl -o /usr/local/bin/pixi
$ chmod +x /usr/local/bin/pixi
$ mkdir /tmp/test /tmp/bin
$ echo"echo I am a mock python"> /tmp/bin/python3
$ chmod +x /tmp/bin/python3
$ echo'export PATH=/tmp/bin:$PATH'>>~/.bashrc
$ bash
$ cd /tmp/test
$ pixi init
$ pixi add python
$ which python3
/tmp/bin/python3
$ pixi run which python3
/tmp/test/.pixi/env/bin/python3
$ pixi shell
$ which python3
$ /tmp/bin/python3
This will probably be a common issue since AFAIK homebrew explicitly wants that eval "$(/opt/homebrew/bin/brew shellenv)" is somewhere in your zshrc (and python and other tools will probably also be installed in there).
changed the title [-]`pixi shell` has different PATH than `pixi run`[/-][+]`pixi shell` has different PATH than `pixi run` when PATH gets modified in rc files[/+]on Aug 2, 2023
micromamba shell currently doesn't work at all for me 😅 it always drops me in the base environment. But even in base, this has the same issues. @jonashaag also checked out what nix does but they apparently seem to have the same problem.
I dug a little deeper into how poetry / pexpect and ptyprocess work.
I think they are doing quite a lot more wrt to terminal emulation than rexpect (the Rust port of pexpect) does, especially in terms of how things like backspace etc. are handled. I might also have done things wrongly, I might need a night of sleep on it. But so far I am thinking we should first implement the "hacks" for bash & zsh (that we execute the activation script after sourcing the bashrc) and then later try more with rexpect.
Activity
ruben-arts commentedon Aug 2, 2023
He @pavelzw,
That would be bad, i'm not able to reproduce it locally:
Also my in pixi's environment paths are equal:
pavelzw commentedon Aug 2, 2023
When I compare both
PATHs, I can see thatpixi runhas.pixi/env/binat the top whilepixi shelldoesn't.We can see that in
pixi shellit adds the additional PATH stuff that I explicitly added in my.zshrcwhile it doesn't do that inpixi run.Can you reproduce the issue with this?
This will probably be a common issue since AFAIK homebrew explicitly wants that
eval "$(/opt/homebrew/bin/brew shellenv)"is somewhere in your zshrc (and python and other tools will probably also be installed in there).You probably need to modify
pixi shells.t.<pixi-env>/bingets added toPATHas a last step, even after the rc file sourcing.[-]`pixi shell` has different PATH than `pixi run`[/-][+]`pixi shell` has different PATH than `pixi run` when PATH gets modified in rc files[/+]ruben-arts commentedon Aug 2, 2023
Thanks for the extended repro! This was indeed because the start script for
pixi shelllooks this if you're in bash:Not really sure what the clean way go do this would be.
baszalmstra commentedon Aug 14, 2023
@pavelzw does the same thing happen when you use
micromamba shell?pavelzw commentedon Aug 14, 2023
micromamba shellcurrently doesn't work at all for me 😅 it always drops me in the base environment. But even in base, this has the same issues. @jonashaag also checked out what nix does but they apparently seem to have the same problem.Maybe this could be an option? https://stackoverflow.com/a/36152028/18839600
pixi shell = bash --rcfile <(echo '. ~/.bashrc; export PATH=<PIXI-stuff>:$PATH')baszalmstra commentedon Aug 14, 2023
Haha wow, that looks super hacky! I like it!
Is there something similar for
zshand other shells?pavelzw commentedon Aug 14, 2023
Seems to be shell specific. By playing around with zsh, I got this to work
ruben-arts commentedon Aug 22, 2023
This is poetry's solution for this issue.
I'm going to try to do this in our activation.
baszalmstra commentedon Aug 24, 2023
I created another issue that encapsulates all issues with our current solution and a way forward. Please follow that issue for progress!
wolfv commentedon Aug 25, 2023
I dug a little deeper into how poetry / pexpect and ptyprocess work.
I think they are doing quite a lot more wrt to terminal emulation than
rexpect(the Rust port ofpexpect) does, especially in terms of how things like backspace etc. are handled. I might also have done things wrongly, I might need a night of sleep on it. But so far I am thinking we should first implement the "hacks" for bash & zsh (that we execute the activation script after sourcing the bashrc) and then later try more with rexpect.ruben-arts commentedon Sep 29, 2023
This is fixed in #316.
The pixi environment now gets activated after the shell is started thus overwriting the parts from your rc files.
The repro now works if you build pixi in the docker container.
Funnily enough that is what this example does so you can use that to test this.