pixi.lock file is a lock file that records the exact versions of all packages installed in your environments. It ensures reproducible installations across different machines and over time.
Overview
The lock file is automatically generated by pixi and should be committed to version control. It contains:- Exact package versions and builds
- Package URLs and hashes
- Dependency relationships
- Platform-specific packages
- Environment configurations
Lock File Location
The lock file is always namedpixi.lock and placed in the workspace root, next to pixi.toml or pyproject.toml.
When is it Generated?
The lock file is created or updated when:- Running
pixi install - Running
pixi addorpixi remove - Running
pixi run(if lock file is outdated) - Running
pixi update - Manually running
pixi lock
- Using
--frozenflag - Using
--lockedflag (fails instead if outdated) - Lock file is already up-to-date with manifest
File Format
The lock file uses a custom TOML-based format optimized for readability and merge-friendliness.Basic Structure
Metadata Section
channels- Channels used during solveplatforms- Target platformscontent_hash- Hash of manifest content for validation
Environments Section
Package Entries
Each package is recorded with complete information:name- Package nameversion- Exact versionbuild- Build stringbuild_number- Build numbersubdir- Platform (linux-64, osx-64, etc.)url- Download URLsha256/md5- Checksums for verificationsize- Package size in bytestimestamp- Build timestampdepends- Runtime dependencies
PyPI Packages
PyPI packages are recorded separately:Version Control
Should I Commit pixi.lock?
Yes! Always commitpixi.lock to version control.
Why commit the lock file?
Why commit the lock file?
- Reproducibility: Ensures everyone gets the same package versions
- Determinism: Builds are consistent across environments
- History: Track dependency changes over time
- Debugging: Know exactly what versions were used
- CI/CD: Reliable automated builds
Lock file in .gitignore?
Lock file in .gitignore?
No! Do not add
pixi.lock to .gitignore.Only ignore environment directories:Handling Merge Conflicts
If you get a merge conflict inpixi.lock:
-
Accept either version:
-
Regenerate lock file:
-
Commit resolved lock file:
Lock File Commands
Update lock file
Use existing lock file
Validate lock file
Lock File vs Manifest
Understanding the difference:| Aspect | Manifest (pixi.toml) | Lock File (pixi.lock) |
|---|---|---|
| Purpose | Declare requirements | Record exact versions |
| Format | TOML | TOML (internal format) |
| Edit | Manually | Automatically |
| Commit | Yes | Yes |
| Versions | Constraints (>=1.20) | Exact (1.26.4) |
| Hashes | No | Yes |
| URLs | No | Yes |
Reproducibility
The lock file provides reproducibility through:- Exact versions: No version ranges, specific builds
- Checksums: SHA256/MD5 hashes verify package integrity
- URLs: Direct download links (with fallbacks)
- Dependencies: Full dependency tree recorded
- Platforms: Platform-specific packages for each target
Example: Reproducible CI
Lock File Optimization
Pixi optimizes the lock file for:- Merge-friendliness: Deterministic ordering
- Readability: Human-readable TOML
- Size: Compressed format for large dependency trees
- Performance: Fast parsing and lookup
Troubleshooting
Lock file is out of date
Lock file is out of date
Error: “Lock file is out of date with the manifest”Solution:
Lock file conflicts in merge
Lock file conflicts in merge
Problem: Git merge conflict in pixi.lockSolution:
Lock file is huge
Lock file is huge
Problem: Lock file is very largeCause: Large dependency trees, many platformsSolution:
- Reduce number of platforms if not needed
- Consider splitting environments
- This is normal for complex projects
Corrupted lock file
Corrupted lock file
Error: “Failed to parse lock file”Solution:
Related Commands
pixi install- Install from lock filepixi update- Update lock filepixi lock- Generate lock file without installing
Related Configuration
--frozen- Don’t update lock file--locked- Require up-to-date lock filePIXI_FROZEN- Environment variable