Skip to content

feat: add --dry-run flag to pixi lock command#5288

Merged
ruben-arts merged 8 commits intoprefix-dev:mainfrom
akshatsrivastava11:add--dry-run-to-lock-cli
Jan 20, 2026
Merged

feat: add --dry-run flag to pixi lock command#5288
ruben-arts merged 8 commits intoprefix-dev:mainfrom
akshatsrivastava11:add--dry-run-to-lock-cli

Conversation

@akshatsrivastava11
Copy link
Contributor

Description

This PR adds a --dry-run flag to the pixi lock command, addressing issue # #5280 .

How Has This Been Tested?

I verified the changes by building the binary from source and testing the flag's behavior in a local environment.

 ./target/debug/pixi lock --json --dry-run > diff.json

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added sufficient tests to cover my changes.
  • I have verified that changes that would impact the JSON schema have been made in schema/model.py.

Copy link
Contributor

@baszalmstra baszalmstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try to add a test that verifies that this indeed doesnt update the lock-file?

match self {
LockFileUsage::Update | LockFileUsage::Locked => true,
LockFileUsage::Frozen => false,
LockFileUsage::DryRun => false,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're absolutely right!
With DryRun => true, the dependency resolution happens and the diff is computed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @johnnyg :)

async fn test_lock_dry_run_doesnt_modify_lockfile() {
// Create a new pixi project
let pixi = PixiControl::new().unwrap();
pixi.init().with_channel("conda-forge").await.unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the test reach out the the internet. You can use MockRepoData to setup a local channel, this both improves the performance, makes it more targeted, and less flaky.

@tdejager
Copy link
Contributor

tdejager commented Jan 16, 2026

Should we instead of calling it --dry-run call it --dont-write or something? :)

@tdejager
Copy link
Contributor

Case against my point uv does seem to call it --dry-run.

Copy link
Contributor

@baszalmstra baszalmstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good but Ill ask @ruben-arts to check the UX.

Copy link
Contributor

@ruben-arts ruben-arts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, ux wise it fits the rest of pixi, merging it in!

@ruben-arts ruben-arts merged commit c75d30b into prefix-dev:main Jan 20, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants