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

error: failed to select a version for hidapi. #9294

Closed
ndcroos opened this issue Mar 22, 2021 · 2 comments · Fixed by #9568
Closed

error: failed to select a version for hidapi. #9294

ndcroos opened this issue Mar 22, 2021 · 2 comments · Fixed by #9568
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-bug Category: bug E-easy Experience: Easy

Comments

@ndcroos
Copy link

ndcroos commented Mar 22, 2021

Problem

I am trying to add the crate 'hidapi' to my project, but I have a dependency issue. I don't know how to resolve this.

When I execute cargo build, I get the following:

$ cargo build
    Updating crates.io index
error: failed to select a version for `hidapi`.
    ... required by package `ledger-transport-hid v0.8.0`
    ... which is depended on by `ledger-transport v0.8.0`
    ... which is depended on by `test-ledger-rs v0.1.0 (/home/nick-test/test-ledger-rs2)`
versions that meet the requirements `^1.2.3` are: 1.2.5, 1.2.3

the package `hidapi` links to the native library `hidapi`, but it conflicts with a previous package which links to `hidapi` as well:
package `hidapi v0.5.2`
    ... which is depended on by `ledger v0.2.5`
    ... which is depended on by `test-ledger-rs v0.1.0 (/home/nick-test/test-ledger-rs2)`

When I change the hidapi versio, the error remains.

Steps

  1. Add the following to the Cargo.toml file:

ledger = "0.2.5"
ledger-transport-hid = "0.8.0"
ledger-apdu = "0.8.0"
ledger-transport = "0.8.0"
hidapi = "0.5.2"

  1. Execute cargo build

  2. Eventually, change hidapi to other versions that meet the requirements.

Notes

Output of cargo version: cargo 1.49.0 (d00d64d 2020-12-05)

I am working on Debian 10.

@ndcroos ndcroos added the C-bug Category: bug label Mar 22, 2021
@Eh2406
Copy link
Contributor

Eh2406 commented Mar 22, 2021

Indeed they are not compatible.
ledger depends on = 0.5.2 of hidapi and
ledger-transport-hid depends on ^1.2.3 of hidapi.
So you will need to find versions that are intended to work together. It looks like there is no version of ledger-transport-hid without that requirement, so as someone that dose not know the libraries, I don't know what to advice.

@ehuss ehuss added A-diagnostics Area: Error and warning messages generated by Cargo itself. E-easy Experience: Easy labels Jun 2, 2021
@ehuss
Copy link
Contributor

ehuss commented Jun 2, 2021

Leaving open to perhaps extend the error message with a little more information. I'm thinking a note after the error that maybe says something like the following:

Only one package in the dependency graph may specify the same links value. This helps ensure that only one copy of a native library is linked in the final binary. Try to adjust your dependencies so that only one package uses the links = 'hidapi' value. For more information, see https://doc.rust-lang.org/cargo/reference/resolver.html#links.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-bug Category: bug E-easy Experience: Easy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants