Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore Cargo.lock with --no-dev-deps #187

Closed
punkeel opened this issue May 4, 2023 · 5 comments
Closed

Restore Cargo.lock with --no-dev-deps #187

punkeel opened this issue May 4, 2023 · 5 comments
Labels
C-enhancement Category: A new feature or an improvement for an existing one

Comments

@punkeel
Copy link
Contributor

punkeel commented May 4, 2023

Hey there,

It looks like cargo hack does not properly restore Cargo.lock after running.

~/Code/yyy/xxx ❯ cargo hack check --verbose --all --feature-powerset --no-dev-deps
info: --no-dev-deps removes dev-dependencies from real `Cargo.toml` while cargo-hack is running and restores it when finished
info: removing dev-dependencies from /Users/maxime/Code/yyy/xxx/crates/xxx/Cargo.toml
info: removing dev-dependencies from /Users/maxime/Code/yyy/xxx/crates/xxx_config/Cargo.toml
info: removing dev-dependencies from /Users/maxime/Code/yyy/xxx/crates/xxx_metrics_server/Cargo.toml
info: running `/Users/maxime/.rustup/toolchains/stable-aarch64-apple-darwin/bin/cargo check --manifest-path crates/xxx/Cargo.toml --no-default-features` (1/3)
    Finished dev [unoptimized + debuginfo] target(s) in 0.09s

info: running `/Users/maxime/.rustup/toolchains/stable-aarch64-apple-darwin/bin/cargo check --manifest-path crates/xxx_config/Cargo.toml --no-default-features` (2/3)
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s

info: running `/Users/maxime/.rustup/toolchains/stable-aarch64-apple-darwin/bin/cargo check --manifest-path crates/xxx_metrics_server/Cargo.toml --no-default-features` (3/3)
    Blocking waiting for file lock on package cache
    Finished dev [unoptimized + debuginfo] target(s) in 0.12s
info: restoring /Users/maxime/Code/yyy/xxx/crates/xxx/Cargo.toml
info: restoring /Users/maxime/Code/yyy/xxx/crates/xxx_config/Cargo.toml
info: restoring /Users/maxime/Code/yyy/xxx/crates/xxx_metrics_server/Cargo.toml
~/Code/yyy/xxx ❯ git st
HEAD detached from origin/main
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   Cargo.lock

no changes added to commit (use "git add" and/or "git commit -a")

~/Code/yyy/xxx ❯ git diff
 [[package]]
 name = "linux-raw-sys"
-version = "0.3.6"
+version = "0.3.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b64f40e5e03e0d54f03845c8197d0291253cdbedfb1cb46b13c2c117554a9f4c"
+checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f"
# ... and more minor version bumps
@taiki-e

This comment was marked as outdated.

@taiki-e
Copy link
Owner

taiki-e commented May 4, 2023

Oh, nah, cargo-hack doesn't restore lockfile in the first place.

@punkeel
Copy link
Contributor Author

punkeel commented May 4, 2023

I can confirm the “bug” happens even if my editor is closed, and inside an isolated environment (CI)

@taiki-e taiki-e changed the title Cargo.lock not properly restored with --no-dev-deps Restore Cargo.lock with --no-dev-deps May 4, 2023
@taiki-e taiki-e added the C-enhancement Category: A new feature or an improvement for an existing one label May 4, 2023
@taiki-e
Copy link
Owner

taiki-e commented May 4, 2023

Well, this was originally intentional behavior. To be able to figure out in which lockfile cargo was executed on.

That said, my other cargo subcommands (cargo-minimal-versions, cargo-no-dev-deps) restore lockfile by default, so changing the default behavior here would be fine.

This should be able to be implemented by just copying a few lines from my other cargo subcommands.
https://github.com/taiki-e/cargo-no-dev-deps/blob/c5eba4a5a38a4438086996211df053fb1d9482d3/src/main.rs#L97-L103
https://github.com/taiki-e/cargo-minimal-versions/blob/ffe339d42bf9166e0b9c078700d02ac6d07a7c5f/src/main.rs#L69-L75

@taiki-e
Copy link
Owner

taiki-e commented Aug 28, 2023

Implemented in 0.6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: A new feature or an improvement for an existing one
Projects
None yet
Development

No branches or pull requests

2 participants