Skip to content

Conversation

@fstanis
Copy link
Contributor

@fstanis fstanis commented Oct 16, 2025

This PR fixes #4648.

Currently, on Windows (via #3981) we launch bash by creating a new bash process with --init-file which contains all the environment variables, completions and custom prompt.

This doesn't work for other shells unfortunately since --init-file is bash-specific. This PR splits the init file into two parts: one for the environment variables (called init_file in code), which uses bash syntax, and the other one for completions and custom prompt, which is specific to the shell that's starting (called env_file in code).

pixi shell therefore first starts bash in a new process with the init_file, then one of two things happens:

  • If we're using fish, we use exec for fish to "take over" the bash process, sourcing env_file in the process.
  • If we're using bash, we simply source the file with env_file.

This logic should be possible to reuse for xonsh and zsh as well, although someone more knowledgeable would need to clarify how to best perform the "take over" step for those shells.

@fstanis fstanis changed the title Add support for Fish on Windows feat: support for Fish on Windows Oct 16, 2025
command.arg("--init-file");
command.arg(&temp_path);
command.arg(&init_file_path);
command.arg("-i");
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if you could leave the bash --init-file logic the same as before, and switch this -i into -c fish -i when the shell is fish?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried that initially and, unfortunately, it didn't work. While fish inherits the environment variables from the parent bash, it can't inherit the functions (i.e. prompt and completions) because those are shell-specific. So either that would start fish without the prompt or shell completion (if we always use those for bash regardless of shell) or would fail completely (because fish function syntax is incompatible with bash).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thinking about it, we could probably just skip completions and prompt for zsh for now (or for fish as well, if we want to make this code simpler) and possibly tell the user how to add these manually by editing their .zshrc / config.fish.

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.

Support pixi shell with fish and Windows

2 participants