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

Do not call it "Downgrading" when difference is only build metadata #12796

Merged
merged 4 commits into from
Oct 11, 2023

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented Oct 9, 2023

What does this PR try to resolve?

When a cargo update --precise changes a dependency between 2 versions which differ only in build metadata, Cargo prints a log referring to it as "Updating" or "Downgrading" the dependency, depending on a comparison between the build metadatas.

This is usually not meaningful, given that build metadata is often stuff like git commit hashes, which are not meaningfully ordered.

    Updating crates.io index
 Downgrading foo v0.0.1+43ef4fe -> v0.0.1+2c65d16
    Updating bar v0.0.2+bc17664 -> v0.0.2+c144a98

This PR changes to the word "Switching" when the version major, minor, patch, and pre-release value are not being changed.
This PR uses the word "Updating" when the version major, minor, patch, and pre-release value are unchanged, regardless of whether the build metadata is going up or down.

How should we test and review this PR?

  • cargo test
  • cargo build --release
  • /path/to/cargo/target/release/cargo add tonic_datastore_v1
  • /path/to/cargo/target/release/cargo update -p tonic_datastore_v1 --precise 0.1.0+3562b6cb3
  • /path/to/cargo/target/release/cargo update -p tonic_datastore_v1 --precise 0.1.0+ee9e8e4e6

Before:

After:

After:

@rustbot
Copy link
Collaborator

rustbot commented Oct 9, 2023

r? @epage

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added A-testing-cargo-itself Area: cargo's tests Command-generate-lockfile S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 9, 2023
@epage
Copy link
Contributor

epage commented Oct 9, 2023

What I'm wondering is if this is worth defining the semantics for seeing as

@dtolnay
Copy link
Member Author

dtolnay commented Oct 9, 2023

The documentation is that you shouldn't publish two versions that differ only in build metadata, but this case can arise locally without publishing. A path dependency or git dependency might change build metadata without the previous build metadata ever being published. cargo update prints its "Updating" / "Downgrading" message in this case.

@dtolnay dtolnay changed the title Do not call it "Updating" or "Downgrading" when difference is only build metadata Do not call it "Downgrading" when difference is only build metadata Oct 9, 2023
@dtolnay
Copy link
Member Author

dtolnay commented Oct 9, 2023

custom_target::changing_spec_relearns_crate_types failure on "Windows x86_64 gnu nightly" appears unrelated: "linking with `rust-lld` failed: exit code: 0xc0000374".
---- custom_target::changing_spec_relearns_crate_types stdout ----
running `D:\a\cargo\cargo\target\debug\cargo.exe build --lib --target custom-target.json -v`
running `D:\a\cargo\cargo\target\debug\cargo.exe build --lib --target custom-target.json -v`
thread 'custom_target::changing_spec_relearns_crate_types' panicked at tests\testsuite\custom_target.rs:218:10:

test failed running `D:\a\cargo\cargo\target\debug\cargo.exe build --lib --target custom-target.json -v`
error: process exited with code 101 (expected 0)
--- stdout

--- stderr
   Compiling foo v0.1.0 (D:\a\cargo\cargo\target\tmp\cit\t1117\foo)
     Running `rustc --crate-name foo src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type cdylib --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=987467f931cbf061 --out-dir D:\a\cargo\cargo\target\tmp\cit\t1117\foo\target\custom-target\debug\deps --target \\?\D:\a\cargo\cargo\target\tmp\cit\t1117\foo\custom-target.json -L dependency=D:\a\cargo\cargo\target\tmp\cit\t1117\foo\target\custom-target\debug\deps -L dependency=D:\a\cargo\cargo\target\tmp\cit\t1117\foo\target\debug\deps`
error: linking with `rust-lld` failed: exit code: 0xc0000374
  |
  = note: "rust-lld" "-flavor" "gnu" "--version-script=C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\rustcwHhD0U\\list" "--no-undefined-version" "D:\\a\\cargo\\cargo\\target\\tmp\\cit\\t1117\\foo\\target\\custom-target\\debug\\deps\\foo.foo.22cab9f376391196-cgu.0.rcgu.o" "--as-needed" "-L" "D:\\a\\cargo\\cargo\\target\\tmp\\cit\\t1117\\foo\\target\\custom-target\\debug\\deps" "-L" "D:\\a\\cargo\\cargo\\target\\tmp\\cit\\t1117\\foo\\target\\debug\\deps" "-L" "C:\\Users\\runneradmin\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\custom-target\\lib" "-Bdynamic" "--eh-frame-hdr" "-z" "noexecstack" "-L" "C:\\Users\\runneradmin\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\custom-target\\lib" "-o" "D:\\a\\cargo\\cargo\\target\\tmp\\cit\\t1117\\foo\\target\\custom-target\\debug\\deps\\libfoo.so" "--gc-sections" "-shared"
  = note: 

error: could not compile `foo` (lib) due to previous error

Caused by:
  process didn't exit successfully: `rustc --crate-name foo src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type cdylib --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=987467f931cbf061 --out-dir D:\a\cargo\cargo\target\tmp\cit\t1117\foo\target\custom-target\debug\deps --target \\?\D:\a\cargo\cargo\target\tmp\cit\t1117\foo\custom-target.json -L dependency=D:\a\cargo\cargo\target\tmp\cit\t1117\foo\target\custom-target\debug\deps -L dependency=D:\a\cargo\cargo\target\tmp\cit\t1117\foo\target\debug\deps` (exit code: 1)

failures:
    custom_target::changing_spec_relearns_crate_types

@rustbot rustbot added A-registries Area: registries A-semver Area: semver specifications, version matching, etc. labels Oct 11, 2023
@epage
Copy link
Contributor

epage commented Oct 11, 2023

Thanks for your patience in applying the feedback and not just addressing this but stopping the bleed of "yet one more place we do this" and going beyond that, looking to the bigger picture of what the API should be for semver

@bors r+

@bors
Copy link
Contributor

bors commented Oct 11, 2023

📌 Commit f1d2237 has been approved by epage

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 11, 2023
@bors
Copy link
Contributor

bors commented Oct 11, 2023

⌛ Testing commit f1d2237 with merge 90fb62f...

@bors
Copy link
Contributor

bors commented Oct 11, 2023

☀️ Test successful - checks-actions
Approved by: epage
Pushing 90fb62f to master...

@bors bors merged commit 90fb62f into rust-lang:master Oct 11, 2023
22 checks passed
@dtolnay dtolnay deleted the switching branch October 11, 2023 15:39
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 17, 2023
Update cargo

17 commits in 6fa6fdc7606cfa664f9bee2fb33ee2ed904f4e88..ff768b45b302efd488178b31b35489e4fabb8799
2023-10-10 23:06:08 +0000 to 2023-10-17 12:51:31 +0000
- Clarify flag behavior in `cargo remove --help` (rust-lang/cargo#12823)
- doc(cargo-login): mention args after `--` in manpage (rust-lang/cargo#12832)
- changelog: add compat notice for `cargo login -- <arg>` (rust-lang/cargo#12830)
- update SPDX License info (rust-lang/cargo#12827)
- Add test for `-V` short argument (rust-lang/cargo#12822)
- add detailed message when target folder path is invalid (rust-lang/cargo#12820)
- chore(deps): update rust crate toml_edit to 0.20.2 (rust-lang/cargo#12761)
- Support `public` dependency configuration with workspace deps (rust-lang/cargo#12817)
- Update rustix to 0.38.18 (rust-lang/cargo#12815)
- contrib docs: add some conveniences (rust-lang/cargo#12812)
- Better suggestion for unsupported `--path` flag (rust-lang/cargo#12811)
- contrib docs: update rfc and roadmap links (rust-lang/cargo#12814)
- contrib doc: remove extraneous word (rust-lang/cargo#12813)
- Update curl-sys to pull in curl 8.4.0 (rust-lang/cargo#12808)
- feat: add package name and version to warning messages (rust-lang/cargo#12799)
- Do not call it "Downgrading" when difference is only build metadata (rust-lang/cargo#12796)
- Add unsupported short flag suggestion for `--target` and `--exclude` flags (rust-lang/cargo#12805)

r? ghost
@ehuss ehuss added this to the 1.75.0 milestone Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-registries Area: registries A-semver Area: semver specifications, version matching, etc. A-testing-cargo-itself Area: cargo's tests Command-generate-lockfile S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants