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

[clap_derive] version conflict with proc-macro2 #3307

Closed
2 tasks done
hasezoey opened this issue Jan 18, 2022 · 7 comments
Closed
2 tasks done

[clap_derive] version conflict with proc-macro2 #3307

hasezoey opened this issue Jan 18, 2022 · 7 comments
Labels
A-derive Area: #[derive]` macro API C-bug Category: Updating dependencies S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.

Comments

@hasezoey
Copy link

hasezoey commented Jan 18, 2022

Please complete the following tasks

  • I have searched the discussions
  • I have searched the existing issues

Rust Version

rustc 1.58.0 (02072b482 2022-01-11)

Clap Version

3.0.9

Minimal reproducible code

clap features used: "derive", "wrap_help", "env"

use clap::*;

fn main() {}

Steps to reproduce the bug with the above code

  1. cargo build

Actual Behaviour

error: failed to select a version for `proc-macro2`.
    ... required by package `clap_derive v3.0.0`
    ... which satisfies dependency `clap_derive = "^3.0.0"` of package `clap v3.0.9`
    ... which satisfies dependency `clap = "^3.0.9"` (locked to 3.0.9) of package `yt-downloader-rust v0.4.0 (/mnt/projects/rust/yt-downloader)`
versions that meet the requirements `^1.0.28` are: 1.0.36, 1.0.35, 1.0.34, 1.0.33, 1.0.32, 1.0.31, 1.0.30, 1.0.29, 1.0.28

all possible versions conflict with previously selected packages.

  previously selected package `proc-macro2 v1.0.26`
    ... which satisfies dependency `proc-macro2 = "^1.0.20"` (locked to 1.0.26) of package `quote v1.0.9`
    ... which satisfies dependency `quote = "^1.0.9"` (locked to 1.0.9) of package `clap_derive v3.0.0`
    ... which satisfies dependency `clap_derive = "^3.0.0"` of package `clap v3.0.9`
    ... which satisfies dependency `clap = "^3.0.9"` (locked to 3.0.9) of package `yt-downloader-rust v0.4.0 (/mnt/projects/rust/yt-downloader)`

failed to select a version for `proc-macro2` which could resolve this conflict

Expected Behaviour

no version conflict error

Additional Context

Currently, clap_derive requires quote at locked version 1.0.9 which in turn required proc-macro2 at locked version 1.0.20, but clap_derive requires locked version of 1.0.28 for proc-macro2

How can this be fixed:

  • upgrade all version to match
  • unlock the patch version for at least one of the mentioned packages with symbol ~ (like ~1.0.9)

Debug Output

No response

@hasezoey hasezoey added the C-bug Category: Updating dependencies label Jan 18, 2022
@hasezoey
Copy link
Author

for reference see clap_derive Cargo.toml:

quote = "1.0.9"
proc-macro2 = "1.0.28"

and quote's Cargo.toml for version 1.0.9:
https://github.com/dtolnay/quote/blob/68ebadbc1b4242531c5a78fbba01c648bd58c8e7/Cargo.toml#L16

@epage
Copy link
Member

epage commented Jan 18, 2022

Can you provide your Cargo.toml file? I am not able to reproduce this.

Currently, clap_derive requires quote at locked version 1.0.9 which in turn required proc-macro2 at locked version 1.0.20, but clap_derive requires locked version of 1.0.28 for proc-macro2

quote = "1.0.9" is short for quote = "^1.0.9" which means "be semver compatible, but at least 1.0.9. proc-macro2 and quote should gracefully resolve, like they are currently doing on my machine and CI.

@epage epage added A-derive Area: #[derive]` macro API S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 18, 2022
@epage
Copy link
Member

epage commented Jan 18, 2022

I've not run into this myself but this almost sounds like the Cargo.lock file has gotten into an inconsistent state where two different dependency branches are locked to different versions of proc-macro2.

An easy way to verify this is to backup your Cargo.lock (which happens automatically if you have it committed), delete it, and rebuild.

@hasezoey
Copy link
Author

quote = "1.0.9" is short for quote = "^1.0.9" which means "be semver compatible, but at least 1.0.9. proc-macro2 and quote should gracefully resolve, like they are currently doing on my machine and CI.

right, forgot rust handles non-operator versions differently than js packages
but if that is not the case, it just makes the situation more unclear

Can you provide your Cargo.toml file? I am not able to reproduce this.

sure, the project it is happening on is open-source:

Reproduction:

  • clone repository
  • checkout to commit 309d77a1a8b7812ef730a7c974512160679b88ac
  • build once (cargo build --all)
  • replace feature yaml with derive in Cargo.toml for dependency clap
  • try to build (cargo build --all)

I've not run into this myself but this almost sounds like the Cargo.lock file has gotten into an inconsistent state where two different dependency branches are locked to different versions of proc-macro2.

i had now also tried deleting the file, which suddenly everything compiled again (i dont quite understand why though)

i had even tried compiling with only clap dependencies (the other dependencies commented out)

@epage
Copy link
Member

epage commented Jan 19, 2022

Looks like this is unexpected cargo behavior, so closing this out. No idea if cargo has an issue already or not for this problem or if this is expected.

i had even tried compiling with only clap dependencies (the other dependencies commented out)

Removing dependencies in Cargo.toml won't necessarily cause the versions to be re-evaluated in Cargo.lock.

@hasezoey
Copy link
Author

Removing dependencies in Cargo.toml won't necessarily cause the versions to be re-evaluated in Cargo.lock.

i just mentioned i tried this, though i had no clue if this even affected anything

Looks like this is unexpected cargo behavior, so closing this out. No idea if cargo has an issue already or not for this problem or if this is expected.

yes definitely looks like a cargo issue, filed as rust-lang/cargo#10307, for anyone interested

@ta32
Copy link

ta32 commented Dec 21, 2022

I had this issue after adding the feature derive.

I deleted the cargo.lock file but the issue persisted ( I think it was because I had the project open with clion?)

I just added the dependency it wanted to the cargo.toml directly
eg: proc-macro2 = "1.0.28"

The lock file was modified and I removed the dependency and it built.

There is an issue open in cargo. rust-lang/cargo#10307

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-derive Area: #[derive]` macro API C-bug Category: Updating dependencies S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

No branches or pull requests

3 participants