A lock file is the protector of the environments, and Pixi is the key to unlock it.The lock file is crucial for creating reproducible environments. It captures the exact state of your environment, ensuring everyone working on your project uses identical package versions.
What is a Lock File?
A lock file locks the environment in a specific state. In Pixi, thepixi.lock file contains two main definitions:
1. Environment Definitions
Lists all packages for each environment and platform:2. Package Definitions
Complete metadata for each package:Why Use a Lock File?
Pixi uses lock files for several critical reasons: Save Environment State- Captures complete environment without copying all files
- Enables quick environment recreation
- Much smaller than container images
- Guarantees workspace configuration matches environment
- Prevents “works on my machine” problems
- Aligns with your
pixi.tomlmanifest
- Colleagues get identical environments
- No dependency resolution conflicts
- Reduces onboarding friction
- Run the same environment across machines
- Critical for CI/CD systems
- Easy rollback to working states
When is a Lock File Generated?
The lock file is generated during the solve step of package installation: These commands automatically update the lock file when dependencies change:pixi installpixi runpixi shellpixi shell-hookpixi treepixi listpixi addpixi remove
The lock file is always kept in sync with your
pixi.toml or pyproject.toml manifest.How to Use the Lock File
Thepixi.lock is human-readable, making it easy to track changes in version control:
Lock File Options
All environment commands support lock file usage options: Frozen Mode--frozen is useful in CI/CD to ensure exact reproducibility. --locked fails fast if lock file is out of sync.Syncing Lock File with Manifest
The lock file must match the complete manifest configuration: When you changepixi.toml, Pixi automatically updates the lock file:
Lock File Satisfiability
Pixi checks if the lock file is “satisfiable” - meaning the manifest, lock file, and environment are in sync.Satisfiability Checks
- All environments in manifest exist in lock file
- All channels in manifest exist in lock file
- All packages in manifest are in lock file with compatible versions
- Package versions match manifest requirements (uses conda matchspecs)
- For PyPI dependencies, all Python conda packages have
purlsfields - All hashes for editable PyPI packages are correct
- Only one entry per package exists
If the lock file is not satisfiable, Pixi automatically generates a new one.
Lock File Version
The lock file includes a version for compatibility:- ✅ Newer Pixi can use older lock files
- ❌ Older Pixi cannot use newer lock files
Lock File Size
Lock files can grow large with many packages, but:- Pixi optimizes for minimal size
- Lock files are always smaller than Docker images
- Downloading a small lock file is faster than downloading wrong packages
- The size ensures complete reproducibility
Is your lock file too large?
Is your lock file too large?
If lock file size is a concern:
- It’s still smaller than equivalent container images
- Download time is minimal compared to package downloads
- The completeness prevents costly dependency resolution errors
- Consider it a small price for guaranteed reproducibility
When You Don’t Need a Lock File
You might skip lock files if:- You don’t need reproducible environments
- You’re always building from scratch
- You’re experimenting with package versions