Repository navigation
Description
Checks
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pixi, using
pixi --version.
Reproducible example
pixi shelladditional info:
I use Ubuntu 22.04.3 with ZSH + oh-my-zsh
Issue description
I tried activating a shell using pixi shell and encountered several issues:
-
When the activation takes longer than 1 second, pixi gives a warning.
1.1 The docs URL is wrong: https://pixi.sh/advanced/pixi_shell/#issues-with-pixi-shell
it should be https://pixi.sh/latest/advanced/pixi_shell/#issues-with-pixi-shell
1.2 IMHO, 1 second is reasonable, as pixi validates the lock file, but maybe I just have low standards... maybe we can allow the user to ignore it? e.g., using a flag and/or environment variable -
The warning above disappears quite quickly (it seems the script that's being run clears the terminal). we should consider leaving it on the screen. This also affects debugging - I tried running with
-vvv, but many of the logs are gone... -
Diving into the suggested URL, one of the proposed solutions is using
pixi shell-hook)
3.1 There's a problem with this example:
function pixi_activate() {
# default to current directory if no path is given
local manifest_path="${1:-.}"
eval "$(pixi shell-hook --manifest-path '$manifest_path')" # <-- does not work with the single quotes around manifest_path
# eval "$(pixi shell-hook --manifest-path $manifest_path)" # <-- this one worked for me
}3.2 It's not mentioned how one can deactivate the environment using this method (ctrl+D completely closes the shell, which is unwanted)
Expected behavior
see above
Activity
gzm55 commentedon Apr 7, 2025
from document, there is no
deactivatefunction:this should be fixed with double quotes as
eval "$(pixi shell-hook --manifest-path "$manifest_path")"noamgot commentedon Apr 7, 2025
That's true for
pixi shell, I asked about the equivalent for runningeval "$(pixi shell-hook)"If it works, either of the fixes we proposed should appear in the docs
gzm55 commentedon Apr 7, 2025
it seems there is still no deactivate designed for
shell-hookno quotes parameter in shell may fail if path contains spaces.
wolfv commentedon Apr 7, 2025
Would you be able to send a PR to the docs? That would be very helpful!
wolfv commentedon Apr 7, 2025
I think we shoudl introduce a second option to
shell-hookfor deactivation. That would be useful in this scenario, and the implementation would be quite straight-forward.noamgot commentedon Apr 7, 2025
I'll try to address the docs issues
gzm55 commentedon Apr 7, 2025
if we define
deactivationfunction, inpixi shellmode, deactivation should be exit the shell. whereas used aseval "$(pixi shell-hook)", thedeactivationfunction should works likedeactivationin conda or pip venv to restore thePATHenv.wolfv commentedon Apr 7, 2025
For sure. We already have all the code in place to also generate a "deactivation shell hook" we just don't expose it yet.
Hofer-Julian commentedon Apr 14, 2025
Closing in favor of a more specific issue: #3589
noamgot commentedon Apr 14, 2025
@Hofer-Julian has that been fixed...?
Hofer-Julian commentedon Apr 14, 2025
We didn't push a pull request recently, however, we try to avoid big issues addressing multiple separate problems. If you still encounter this problem, then please open a separate issue 🙂