rustrust-cargo

How to resolve 'cargo add' caused error: failed to select version for the requirement 'hdf5-sys = ^0.3.2' on linux?


I installed rust yesterday and I am in need of the numeric crate for my project. But when I ran 'cargo add numeric' in the terminal i got this error:

Updating crates.io index
error: failed to select a version for the requirement 'hdf5-sys = "^0.3.2"'
version 0.3.2 is yanked
version 0.3.3 is yanked
location searched: crates.io index

I found that attempting to add any other library caused the same error. Attempting to build my project gives the same error. I'm using linux (mint) as OS.

I don't have a clue what to do with this. I'm kind of stuck because I want access to numeric, but not being able to add it as a dependency to my project kind of foils my plans.

How to resolve this? Or where I could report this bug (assuming it isn't by my own doing somehow)?


Solution

  • A crate version being "yanked" means that it is no longer available to use that specific version as a dependency. In this case, the numeric crate specifies that it requires the hdf5-sys crate at version "^0.3.2" as a dependency, which means that it needs a non-yanked version 0.3.n, where n is larger than or equal to 2. The hdf5-sys crate appears to have yanked all versions lower than 0.5.0, which means that crates.io cannot find a version that matches the requirement, giving you the error message.

    As the numeric crate is unmaintained, the only solutions (without manually cloning and migrating the numeric crate) you have would be to either use an earlier version of it that does not have a dependency on hdf5-sys (version 0.0.7 appears to be the latest version satisfying this), or switch to a more maintained n-dimensional vector math library, such as using ndarray with ndarray-linalg.