rust-lang / rust-lang/cargo

specifying different versions in unconditional and target-specific dependency sections causes "multiple rmeta candidates" error

Open
#8,032 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-crate-dependencies A-diagnostics A-target-dependencies C-bug S-needs-design
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

Problem

In a situation like:

[dependencies]
lazy_static = "1"

[target.'cfg(not(windows))'.dependencies]
lazy_static = "0.2"

cargo tries to include both lazy_static libraries, which fails with a "multiple rmeta candidates" error because it can't pick the right library.

Steps

git clone https://github.com/sunshowers/cargo-bug-multiversion
cd cargo-bug-multiversion
cargo doc

or uncomment the line in src/lib.rs then run cargo build.

Possible Solution(s)

Ideally this situation would be detected by cargo, at least when it notices that it's about to put multiple conflicting library paths in the same command.

I guess this is similar to the whole specialization issue in Rust, so if we wawnt to get fancy enough maybe non-overlapping specializations could be allowed?

Notes

Output of cargo version:

cargo 1.42.0 (86334295e 2020-01-31)

This is with the standard rustup stable toolchain on MacOS.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Clone the linked cargo-bug-multiversion reproducer, then run cargo doc and, after uncommenting the line in src/lib.rs, cargo build to observe the multiple rmeta candidates error. Trace how Cargo handles the unconditional and target-specific dependency declarations; done means conflicting library paths are detected and reported clearly or otherwise handled without the compilation failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.