Skip to content

Pixi Pack#

pixi-pack is a simple tool that takes a Pixi environment and packs it into a compressed archive that can be shipped to the target machine.

It can be installed via

pixi global install pixi-pack

Or by downloading our pre-built binaries from the releases page.

Instead of installing pixi-pack globally, you can also use Pixi exec to run pixi-pack in a temporary environment:

pixi exec pixi-pack pack
pixi exec pixi-pack unpack environment.tar

pixi-pack demo pixi-pack demo

You can pack an environment with

pixi-pack pack --manifest-file pixi.toml --environment prod --platform linux-64

This will create a environment.tar file that contains all conda packages required to create the environment.

# environment.tar
| pixi-pack.json
| environment.yml
| channel
|    ├── noarch
|    |    ├── tzdata-2024a-h0c530f3_0.conda
|    |    ├── ...
|    |    └── repodata.json
|    └── linux-64
|         ├── ca-certificates-2024.2.2-hbcca054_0.conda
|         ├── ...
|         └── repodata.json

Unpacking an environment#

With pixi-pack unpack environment.tar, you can unpack the environment on your target system. This will create a new conda environment in ./env that contains all packages specified in your pixi.toml. It also creates an activate.sh (or activate.bat on Windows) file that lets you activate the environment without needing to have conda or micromamba installed.

Cross-platform packs#

Since pixi-pack just downloads the .conda and .tar.bz2 files from the conda repositories, you can trivially create packs for different platforms.

pixi-pack pack --platform win-64

You can only unpack a pack on a system that has the same platform as the pack was created for.

Inject additional packages#

You can inject additional packages into the environment that are not specified in pixi.lock by using the --inject flag:

pixi-pack pack --inject local-package-1.0.0-hbefa133_0.conda --manifest-pack pixi.toml

This can be particularly useful if you build the package itself and want to include the built package in the environment but still want to use pixi.lock from the workspace.

Cache downloaded packages#

You can cache downloaded packages to speed up subsequent pack operations by using the --use-cache flag:

pixi-pack pack --use-cache ~/.pixi-pack/cache

This will store all downloaded packages in the specified directory and reuse them in future pack operations. The cache follows the same structure as conda channels, organizing packages by platform subdirectories (e.g., linux-64, win-64, etc.).

Using a cache is particularly useful when:

  • Creating multiple packs with overlapping dependencies
  • Working with large packages that take time to download
  • Operating in environments with limited bandwidth
  • Running CI/CD pipelines where package caching can significantly improve build times

Unpacking without pixi-pack#

If you don't have pixi-pack available on your target system, you can still install the environment if you have conda or micromamba available. Just unarchive the environment.tar, then you have a local channel on your system where all necessary packages are available. Next to this local channel, you will find an environment.yml file that contains the environment specification. You can then install the environment using conda or micromamba:

tar -xvf environment.tar
micromamba create -p ./env --file environment.yml
# or
conda env create -p ./env --file environment.yml

The environment.yml and repodata.json files are only for this use case, pixi-pack unpack does not use them.

Both conda and mamba are always installing pip as a side effect when they install python, see conda's documentation. This is not different from how pixi works and can lead to solver errors when using pixi-pack's compatibility mode since pixi-pack doesn't include pip by default. You can fix this issue in two ways:

  • Add pip to your pixi.lock file using pixi add pip.
  • Configuring conda (or mamba) to not install pip by default by running conda config --set add_pip_as_python_dependency false (or by adding add_pip_as_python_dependency: False to your ~/.condarc)