Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pixi shell Command Doesn't Work With Fish #864

Closed
2 tasks done
zicklag opened this issue Feb 27, 2024 · 2 comments · Fixed by #981
Closed
2 tasks done

pixi shell Command Doesn't Work With Fish #864

zicklag opened this issue Feb 27, 2024 · 2 comments · Fixed by #981
Labels
🐞 bug Something isn't working 👩‍💻 cli Issue related to CLI

Comments

@zicklag
Copy link

zicklag commented Feb 27, 2024

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

/tmp
➜ cd test/

/tmp/test
➜ pixi shell
 source "/tmp/pixi_env_Tpp.fish"

/tmp/test
➜  source "/tmp/pixi_env_Tpp.fish"
/tmp/pixi_env_Tpp.fish (line 11): $(...) is not supported. In fish, please use '(old_fish_prompt)'.
functions -c fish_prompt old_fish_prompt; function fish_prompt; echo "(test) $(old_fish_prompt)"; end;
                                                                             ^
from sourcing file /tmp/pixi_env_Tpp.fish
source: Error while reading file “/tmp/pixi_env_Tpp.fish”

/tmp/test
➜ tail -n 1 /tmp/pixi_env_Tpp.fish
functions -c fish_prompt old_fish_prompt; function fish_prompt; echo "(test) $(old_fish_prompt)"; end;

/tmp/test
➜ pixi --version
pixi 0.15.1

Issue description

When running pixi shell, I get an error about invalid fish syntax. Running eval (pixi shell-hook) works as expected.

It appears that the issue only happens when setting the prompt, which is not modified by pixi shell-hook, so that's probably why it works.

Expected behavior

I should get a pixi environment shell without an error.

@zicklag zicklag added the 🐞 bug Something isn't working label Feb 27, 2024
@zicklag
Copy link
Author

zicklag commented Feb 28, 2024

Just discovered that eval (pixi shell-hook) does not work properly, as it only sets the path. The proper workaround is to run pixi shell-hook | source.

BTW, since I use starship for my shell prompt. This will actually properly display the pixi environment in the propmpt, even though the shell snippet doesn't actually modify the fish prompt explicitly.

@ruben-arts
Copy link
Contributor

Apparently both pixi shell and starship init fish overwrite the function fish_prompt. We should look into how to avoid that overwrite in fish. Maybe @tdejager knows some tricks?

eval "$(pixi shell-hook)" works but the | source is advised as the shell-hook doesn't need stdin

@ruben-arts ruben-arts added the 👩‍💻 cli Issue related to CLI label Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 👩‍💻 cli Issue related to CLI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants