如何在Cargo中更新git依赖项



我有Cargo.toml中git URL引用的Rust库依赖项,如下所示:

rust_wheel = { git = "https://github.com/jiangxiaoqiang/rust_wheel.git" }

现在我更改了git-reo,并希望更新当前项目的依赖项。我试着使用这个命令:

cargo install rust_wheel --force

但它显示了这个错误:

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.

我已经尝试刷新克利翁的货物依赖关系。它不起作用。我应该如何更新依赖项?还尝试了命令cargo update rust_wheel

无论何时在没有任何其他说明符的情况下(即通过属性revtagbranch(指定git存储库的依赖项,都意味着它被指定为该存储库主分支的最新版本。但无论如何,更新任何依赖项都需要更新项目的Cargo.lock文件。这通常意味着使用cargo update命令。

cargo update

这也将检测到版本或原始要求的任何更改,并相应地更新依赖锁。

我尝试使用这个命令:cargo install rust_wheel --force

这是错误的Cargo命令。cargo install用于将二进制文件安装到系统,而不是安装依赖项。这也是有据可查的。

还尝试了cargo update rust_wheel

语法错误。要发布特定依赖项的更新,请使用-p选项。

cargo update -p rust_wheel

另请参阅:

  • 货运命令上的Rust参考

最新更新