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

fix: add reactivation to pixi shell #982

Merged
merged 5 commits into from
Mar 19, 2024
Merged

Conversation

wolfv
Copy link
Member

@wolfv wolfv commented Mar 14, 2024

TODO:

  • implement for bash
  • implement for fish

fixes #326 #977

@pavelzw
Copy link
Contributor

pavelzw commented Mar 14, 2024

not sure i like this behavior :/ seems a bit too hacky

@wolfv
Copy link
Member Author

wolfv commented Mar 14, 2024

@pavelzw unfortunately there is not really a way around it and it's exactly what conda/mamba/micromamba do. The re-hashing is the crucial step...

@pavelzw
Copy link
Contributor

pavelzw commented Mar 14, 2024

Using direnv with watch_file pixi.lock should fix this issue.

@wolfv
Copy link
Member Author

wolfv commented Mar 14, 2024

yeah, but not everyone uses direnv 😱 I think the change is reasonable enough, and also does something in pixi shell.

@pavelzw
Copy link
Contributor

pavelzw commented Mar 14, 2024

I guess if this is the most magic that it's getting and the shell hook is not used globally but only for pixi shell this change is okay...
Alternatively you could try to catch if pixi add ... is happening inside of pixi shell and if so print

please reload your environment by executing
    eval "$(pixi shell-hook)"

Not sure if this is much better than adding a shell function for pixi, though.

Copy link
Contributor

@baszalmstra baszalmstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do agree that this is a bit magic but I also dont see another way to solve this other than only printing a warning.

At the moment this now only works for shells other than zsh and bash. What if we add a check to pixi add and co to see if you are in a shell and print a warning if thats the case? That requires no magic and should help people that use better shells for which no magic is (yet) implemented.

src/activation.rs Outdated Show resolved Hide resolved
src/prompt.rs Outdated Show resolved Hide resolved
src/prompt.rs Outdated Show resolved Hide resolved
@wolfv
Copy link
Member Author

wolfv commented Mar 14, 2024

I also tested this with fish and nushell and both do not seem to have the same problem as bash & zsh.

I did not test on Windows with

  • git bash
  • powershell
  • cmd.exe

Not sure if these have the problem or not. In any case, even without testing those, I think it's a good change.

@wolfv
Copy link
Member Author

wolfv commented Mar 18, 2024

I think as it stands it's a "strict improvement" over the current state.
I would like to investigate complete shell restart on these commands (ideally when we see that e.g. the lockfile has changed).
I think on UNIX that would be possible.

However, IMO we can merge this, open a new issue, and take it from there.

@ruben-arts ruben-arts enabled auto-merge (squash) March 19, 2024 10:17
@wolfv wolfv disabled auto-merge March 19, 2024 16:02
@wolfv wolfv merged commit 93f838b into prefix-dev:main Mar 19, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pixi shell not re-activating after an add is executed
4 participants