How Channel Priority Works
Channel priority is dictated by the order in theworkspace.channels array, where the first channel has the highest priority.
conda-forgehas the highest prioritypytorchhas medium prioritynvidiahas the lowest priority
Priority Logic
The solver uses the following logic when resolving packages:Example: Package Resolution
With channels:["conda-forge", "my-channel", "your-channel"]
- If package is found in
conda-forge, the solver excludes it frommy-channelandyour-channel - If NOT found in
conda-forge, but found inmy-channel, the solver excludes it fromyour-channel - If only in
your-channel, that version is used
This ensures packages always come from the highest-priority channel available, preventing version conflicts.
Channel-Specific Dependencies
You can pin individual dependencies to specific channels:packagex in my-channel, even though conda-forge has higher priority.
Explicit Priority Values
For advanced scenarios (especially with multiple environments), you can set explicit priority values:Higher numbers = higher priority. Non-specified channels use their array index.
pytorch(priority 10)nvidia(priority 5)conda-forge(priority 0, first in array)
Multi-Environment Channel Priority
When using features with different channels, priority becomes more complex:| Environment | Channels Order |
|---|---|
| default | conda-forge |
| cuda | pytorch, nvidia, conda-forge |
| cpu | pytorch, conda-forge, nvidia |
Feature channels are prepended to workspace channels by default. Use explicit priorities to control order.
Use Case: PyTorch with CUDA
A common scenario is using PyTorch with NVIDIA CUDA drivers:Why This Works
- CUDA packages from
nvidia/label/cuda-11.8.0(highest priority) - NVIDIA packages (like
cuda-cudart) fromnvidiachannel - Most dependencies from
conda-forge(broad compatibility) - PyTorch packages from
pytorchchannel (explicitly pinned)
PyTorch channel is listed last because we want most dependencies from conda-forge. We explicitly pin PyTorch packages to the pytorch channel to avoid issues.
Why Not Put PyTorch First?
Thepytorch channel ships outdated versions of some packages (e.g., old ffmpeg) that break newer PyTorch. By keeping conda-forge first and explicitly pinning PyTorch packages, we get:
- Latest compatible dependencies from conda-forge
- PyTorch packages from the official channel
- No conflicts from outdated pytorch channel packages
Check Channel Priority
Usepixi info to verify channel order for your environments:
Common Patterns
Pattern 1: Conda-forge First
Most projects should start with conda-forge:Pattern 2: Specialized Channel for Specific Packages
Pattern 3: Multiple Specialized Channels
Pattern 4: Environment-Specific Channels
Mirrors and Channel Priority
Channel mirrors don’t change priority logic:Troubleshooting
Wrong Package Version
If you’re getting an unexpected version:- Check channel order with
pixi info - Verify package exists in expected channel
- Use channel-specific dependency if needed
Dependency Conflicts
If solver fails with conflicts:- Check if packages require incompatible dependencies from different channels
- Try reordering channels
- Pin problematic packages to specific channels
- Use explicit priority values
Unexpected Channel Selection
Best Practices
- Start with conda-forge unless you have specific requirements
- Use channel-specific dependencies for packages that must come from a particular source
- Document channel rationale in comments for team members
- Test channel order with
pixi infobefore committing - Use explicit priorities for complex multi-environment setups
- Minimize channel count to reduce solver complexity
- Pin critical packages to specific channels for reproducibility