feat: pixi add skips already-present packages without version spec#6145
Open
benmoss wants to merge 3 commits into
Open
feat: pixi add skips already-present packages without version spec#6145benmoss wants to merge 3 commits into
pixi add skips already-present packages without version spec#6145benmoss wants to merge 3 commits into
Conversation
When a package is already a dependency and `pixi add <pkg>` is called without a version constraint, the command now skips the package instead of upgrading it. This prevents accidental version bumps and makes the behavior consistent with cargo's approach. Users are informed with a clear message and directed to use `pixi upgrade` for intentional version updates. Closes prefix-dev#3936 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
8558337 to
fd4267f
Compare
benmoss
commented
May 18, 2026
baszalmstra
requested changes
May 19, 2026
Contributor
baszalmstra
left a comment
There was a problem hiding this comment.
One small comment but otherwise looks good. Looking at @ruben-arts if this CLI change makes sense to him.
Comment on lines
+339
to
+346
| if skipped.iter().any(|s| { | ||
| package == s.as_str() | ||
| || package.strip_prefix(s.as_str()).is_some_and(|rest| { | ||
| rest.starts_with(|c: char| !c.is_alphanumeric() && c != '-' && c != '_') | ||
| }) | ||
| }) { | ||
| continue; | ||
| } |
Contributor
Author
There was a problem hiding this comment.
This prevents the "✔ Added crane" logs from appearing for packages that we skip. The extra prefix testing is to handle the fact that self.specs is raw strings of MatchSpecs and PyPI requirements. It's kinda hacky though. Let me see if I can make this simpler.
Contributor
Author
There was a problem hiding this comment.
9ca5329 refactors this to use the CondaDependency/PypiDependency types and filter in add.rs
Contributor
|
Sounds good to me. Would love to see the |
…atching Use already-parsed package names (from MatchSpec/Requirement parsing) to filter the display list, avoiding reparsing and fragile string pattern matching. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
pixi add skips already-present packages without version specpixi add skips already-present packages without version spec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a package is already a dependency and
pixi add <pkg>is called without a version constraint, the command now skips the package instead of upgrading it. This prevents accidental version bumps and makes the behavior consistent with cargo's approach.Users are informed with a clear message and directed to use
pixi upgradefor intentional version updates:Explicitly versioned adds like
pixi add crane==2.0still overwrite the existing spec as before.Fixes #3936
How Has This Been Tested?
add_existing_dependency_without_version_is_noopvalidates:pixi add foobar==1)==1)pixi add foobar==2)AI Disclosure
Tools: Claude Code (Claude Opus 4.6)
Checklist: