What is an Environment?
An environment is a collection of files installed into a specific directory that contains:- Executables in the
bindirectory - Libraries in the
libdirectory - Headers in the
includedirectory - Package metadata in the
conda-metadirectory - Environment configuration in the
etcdirectory
.pixi/envs/ within your workspace, keeping your machine clean and isolated.
Environment Activation
Activation makes the environment available for use by modifying environment variables and running activation scripts. Pixi provides multiple ways to activate environments:Activation Methods
Shell ActivationThe
pixi run command uses its own cross-platform shell and has the ability to run tasks defined in your pixi.toml.What Happens During Activation?
When you activate an environment, Pixi:-
Adds the
bindirectory toPATH -
Sets environment variables:
CONDA_PREFIX- Path to the environmentPIXI_PROJECT_NAME- Your project namePIXI_PROJECT_ROOT- Path to your workspacePIXI_PROJECT_VERSION- Project versionPIXI_PROJECT_MANIFEST- Path to pixi.tomlPIXI_ENVIRONMENT_NAME- Active environment namePIXI_ENVIRONMENT_PLATFORMS- Supported platformsPIXI_PROMPT- Shell prompt prefix
- Runs activation scripts from installed packages
pixi shell-hook outputs:
Custom Activation
You can customize activation by adding your own scripts and environment variables to thepixi.toml:
Activation scripts and environment variables are applied by the platform’s shell during activation, before any task runs.
Environment Structure
Environments are stored in.pixi/envs/ with a directory for each environment:
Environment Metadata
Each environment contains a metadata file atconda-meta/pixi with:
environment_lock_file_hash is used to quickly check if the environment is in sync with the lock file, speeding up activation.
Environment Solving
When you run commands that use the environment, Pixi checks if it’s in sync withpixi.lock. If not, Pixi solves the environment:
- Retrieves the best set of packages for your dependencies
- Writes the solution to
pixi.lock - Installs the packages into the environment
- Conda packages: Solved by
rattlerusing theresolvoSAT solver - PyPI packages: Solved by
uvwith lazy metadata resolution
Package Caching and De-duplication
Pixi caches all downloaded packages in a global cache directory:- Linux:
$XDG_CACHE_HOME/rattleror$HOME/.cache/rattler - macOS:
$HOME/Library/Caches/rattler - Windows:
%LOCALAPPDATA%\rattler
- Multiple environments share the same package files on disk
- Packages are effectively stored only once
- Huge disk space savings, especially with large packages like CUDA toolkits
Hard links vs Reflinks
Hard links vs Reflinks
- Hard links point multiple directory entries to the same data on disk. This is safe because Pixi environments are read-only.
- Reflinks (copy-on-write links) behave like instant copies that only use new disk space when modified. Safer than hard links - if a file is accidentally modified, only that environment’s copy is affected.
- Copying is used as a fallback when the cache and workspace are on different mount points.
Cleaning Environments
Remove environments to free up space or force a fresh install:Pixi will automatically recreate environments when needed after cleaning.
Detached Environments
By default, environments are stored inside.pixi/envs/ in your workspace. You can enable detached environments to store them outside your workspace directory.