rust-lang/cargo

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

sunshowers opened this issue · 0 comments

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.