I have a project that has a dependency on the ordered-float package. However when I run
cargo clippy i get the following error:
error[E0514]: found crate `ordered_float` compiled by an incompatible version of rustc
2 | use ordered_float::NotNan;
= note: the following crate versions were found:
crate `ordered_float` compiled by rustc 1.69.0 (84c898d65 2023-04-16) (built from a source tarball): (...)/target/debug/deps/libordered_float-08fda71a48c95728.rmeta
= help: please recompile that crate using this compiler (rustc 1.69.0 (84c898d65 2023-04-16)) (consider running `cargo clean` first)
For more information about this error, try `rustc --explain E0514`.
Now I would like to resolve this error because it annoys me, so I tried doing something along the lines of
cargo update -p ordered-float
cargo remove ordered-float
cargo add ordered-float
but neither resolve the error from clippy. What am I supposed to do to resolve this issue ? Or is there nothing I can do?
✗ cargo version
cargo 1.69.0 (6e9a83356 2023-04-12)
✗ rustc --version
rustc 1.69.0 (84c898d65 2023-04-16) (built from a source tarball)
That note is saying you compiled your project with one version of the compiler, then updated to a different version of the compiler.
cargo build sees your
target/ directory already has compiled versions of your dependencies (including
ordered_floats) and is telling the new version of the compiler, "please compile my crate and link with this version of
ordered_floats I prepared earlier".
The problem is a compiled
*.rlib from one compiler version can't be used by another, so the build fails.
cargo clean to clear out your
target/ directory and rebuild.
It's surprising behavior to me that the compilation process doesn't account for the rustc version when deciding the freshness of dependencies. It's kind of obvious that if dependencies change they should be recompiled, and in a sense the compiler is an implicit dependency of every rust crate...
At the same time I've never experienced any problems like this myself, and while I'm not complaining, I'm a little mystified about why.
the version string looks suspicious. it's not the same rustc from the toolchain installed together with cargo. you must have a custom build of rustc installed on you machine. compare the output of:
rustup which rustc
you should make sure the rustup toolchain is in front of whatever custom build you have in the
$PATH environement variable. you use
rustup run command to do this, for example, the following command will give you a bash shell with the
stable toolchain bin directory prepended to
rustup run stable bash
Apperently I had rust install both via brew and rustup and it messed things up. Using
brew uninstall rust solved the issue. Thanks!
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.