'How do I update git dependencies in Cargo?
I have Rust library dependencies referenced by git URL in Cargo.toml like this:
rust_wheel = { git = "https://github.com/jiangxiaoqiang/rust_wheel.git" }
Now I changed the git repo and want to update the dependencies for my current project. I tried to use this command:
cargo install rust_wheel --force
But it shows this error:
error: there is nothing to install in `rust_wheel v0.1.0`, because it has no binaries
`cargo install` is only for installing programs, and can't be used with libraries.
To use a library crate, add it as a dependency in a Cargo project instead.
I have tried to refresh the cargo dependencies in Clion. It did not work. What should I do to update the dependencies? Also tried the command cargo update rust_wheel.
Solution 1:[1]
Whenever a dependency from a git repository is specified without any other specifiers (namely via the properties rev, tag, or branch), that means that it is specified to the latest revision of the main branch of that repository. But in any case, updating any dependency requires updating the project's Cargo.lock file. This generally means using the cargo update command.
cargo update
This will also detect any changes to the version or origin requirements and update the dependency lock accordingly.
I tried to use this command:
cargo install rust_wheel --force
That is the wrong Cargo command. cargo install is for installing binaries to the system, not to install dependencies. This is well documented too.
Also tried
cargo update rust_wheel.
Wrong syntax. To issue an update of a specific dependency, use the -p option.
cargo update -p rust_wheel
See also:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | E_net4 - Krabbe mit Hüten |
