How to clear the Cargo cache?
Install and run cargo-cache to clear the cache in the ~/.cargo folder: cargo install cargo-cache cargo cache -a
Install and run cargo-cache to clear the cache in the ~/.cargo folder: cargo install cargo-cache cargo cache -a
To add to the given answers, a library compiled as a cdylib (docs) can generate this error when you try to reference it in another project. I solved it by separating the code I wished to reuse in a regular lib project.
cargo install is used to install binary packages that happen to be distributed through crates.io. If you want to use a crate as a dependency, add it to your Cargo.toml. Read the Rust getting started guide and the Cargo getting started guide for further information. In short: cargo new my_project cd my_project echo ‘curl = … Read more
In order for an item to be exported from a library crate, there must be at least one path leading to it in which every component is public. This means that all you need to make an item public within your crate but not exported from the crate (I’ll call this “internal” from now on, … Read more
Add a dependency section to your executable’s Cargo.toml and specify the path: [dependencies.my_lib] path = “../my_lib” or the equivalent alternate TOML: [dependencies] my_lib = { path = “../my_lib” } Check out the Cargo docs for specifying dependencies for more detail, like how to use a git repository instead of a local path.