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

Unhelpful error message when specifying incompatible dependencies #132850

Closed
msrd0 opened this issue Nov 10, 2024 · 1 comment
Closed

Unhelpful error message when specifying incompatible dependencies #132850

msrd0 opened this issue Nov 10, 2024 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@msrd0
Copy link
Contributor

msrd0 commented Nov 10, 2024

Code

**`Cargo.toml`**


[package]
name = "foo"
version = "0.1.0"
publish = false
edition = "2021"

[dependencies]
pulldown-cmark = { version = "0.12.2", default-features = false }

[target.'cfg(any(target_arch = "x86", target_arch = "x86_64"))'.dependencies]
pulldown-cmark = { version = "0.11", default-features = false, features = ["simd"] }


**`src/lib.rs`**


use pulldown_cmark;

Current output

Updating crates.io index
     Locking 1 package to latest compatible version
      Adding pulldown-cmark v0.11.3 (latest: v0.12.2)
  Downloaded pulldown-cmark v0.11.3
  Downloaded 1 crate (145.3 KB) in 0.09s
   Compiling pulldown-cmark v0.11.3
   Compiling pulldown-cmark v0.12.2
   Compiling foo v0.1.0 (/tmp/foo)
error[E0464]: multiple candidates for `rmeta` dependency `pulldown_cmark` found
 --> src/lib.rs:1:5
  |
1 | use pulldown_cmark;
  |     ^^^^^^^^^^^^^^
  |
  = note: candidate #1: /tmp/foo/target/debug/deps/libpulldown_cmark-fad4c8962c375cb9.rmeta
  = note: candidate #2: /tmp/foo/target/debug/deps/libpulldown_cmark-385191dabac2676c.rmeta

For more information about this error, try `rustc --explain E0464`.
error: could not compile `foo` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...

Desired output

error[Exxxx]: multiple candidates for dependency `pulldown_cmark` found
 --> Cargo.toml:11:1
   |
11 | pulldown-cmark = { version = "0.11", default-features = false, features = ["simd"] }
   |
note: previous dependency declared here
 --> Cargo.toml:8:1
   |
 8 | pulldown-cmark = { version = "0.12.2", default-features = false }
   |

Rationale and extra context

From the above error message, I get the feeling that something happened within the rust compiler / package manager / whatever that placed something wrong in the target folder. However, it wasn't a problem with the contents of the target folder but with my dependencies. Therefore, the error message should point there.

Other cases

Rust Version

rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: x86_64-unknown-linux-gnu
release: 1.82.0
LLVM version: 19.1.1

Anything else?

No response

@msrd0 msrd0 added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 10, 2024
@ehuss
Copy link
Contributor

ehuss commented Nov 10, 2024

Thanks for the report! I believe this is a duplicate of rust-lang/cargo#8032, so closing in favor of that. Cargo should not be allowing multiple dependencies with the same name.

@ehuss ehuss closed this as not planned Won't fix, can't repro, duplicate, stale Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants