How Pixi Shell Works
Thepixi shell command launches a fresh shell with the environment activated, instead of modifying your current shell like conda activate.
Activation Mechanism (Unix)
On Unix systems, pixi creates a “fake” PTY session:- Launches a new shell process
- Sends an activation command to stdin:
source /tmp/activation-env-12345.sh - Waits for
PIXI_ENV_ACTIVATEDecho to confirm success - If no confirmation after 3 seconds, issues a warning
Automatic Shell Completions
Shell completions for tools in your environment are loaded automatically:Environment Variables Set by Pixi
Pixi sets these variables when runningpixi run, pixi shell, or pixi shell-hook:
The root directory of the project
The name of the project from the manifest
Path to the manifest file (
pixi.toml or pyproject.toml)The version of the project
The prompt to use in the shell
Name of the active environment
Comma-separated list of platforms supported by the project
Path to the environment (conda compatibility)
Name of the environment (conda compatibility)
Prepended with environment’s bin directory
ONLY in
pixi run: Directory where command was run fromThese variables cannot be overridden by users. For example, setting
PIXI_PROJECT_ROOT in your environment won’t change where pixi looks for the project.Environment Variable Priority
Variables are set with the following priority (highest to lowest):Example 1: task.env > activation.env
Example 2: activation.env > activation.scripts
setup.sh
activation.env wins over activation scripts.
Example 3: activation.scripts > dependency scripts
local_setup.sh
Example 4: dependency scripts > outside variables
Example 5: Complete Priority Chain
app_setup.sh
Activation Cache (Experimental)
Cache environment activation to speed up repeatedpixi run and pixi shell invocations.
Enable Activation Cache
Cache Structure
Cache files are stored in.pixi/activation-env-v0/:
Cache Contents
- Lock file data for the environment
activation.scriptsfrom manifestactivation.envfrom manifest
Force Reactivation
Ignore the cache and force full activation:This is experimental because cache invalidation is complex. Use with caution in production environments.
Common Issues with Pixi Shell
Some shell configurations can interfere with pixi’s activation mechanism.WSL Issue
~/.bashrc
wsl.exe command takes over stdin and prevents activation.
Alternative Shell in bashrc
~/.bashrc
If you want to start an alternative shell, do so from
~/.bash_profile or ~/.profile instead of ~/.bashrc.Alternative: Shell Hook
Ifpixi shell doesn’t work due to the issues above, use pixi shell-hook:
Bash/Zsh
~/.bashrc or ~/.zshrc
Fish
~/.config/fish/config.fish
PowerShell
$PROFILE
Customizing the Prompt
By default, pixi adds(pixi) to your shell prompt.
Disable Prompt Modification
Custom Prompt
ThePIXI_PROMPT variable contains the prompt prefix:
~/.bashrc
Best Practices
- Use
pixi runfor tasks instead of manually activating environments - Use
pixi shellfor interactive work when you need environment access - Avoid modifying PIXI_ variables* as they’re managed by pixi
- Document activation scripts to help team members understand environment setup
- Test activation after adding new activation scripts
- Use shell-hook if pixi shell doesn’t work with your shell configuration
- Enable activation cache for large projects to improve performance