无法使用 cargo uninstall 卸载 ~/.cargo 中的包:包 id 规范匹配没有包

ber*_*kie 3 rust rust-cargo

我在从系统中卸载 Cargo 安装的软件包时遇到问题。

有明显安装在 rand-0.3.22 下的包 $HOME/.cargo

ls ~/.cargo/registry/src/github.com-1ecc6299db9ec823/ra

racer-2.0.14/     rand-0.3.22/      rand-0.4.2/
rand-0.4.3/       rand-0.5.5/       rand_core-0.2.1/
rawpointer-0.1.0/ rayon-1.0.2/      rayon-core-1.4.1/
Run Code Online (Sandbox Code Playgroud)

这也可以通过使用来验证 cargo pkgid

cargo pkgid -p rand

error: There are multiple `rand` packages in your project, and the specification `rand` is ambiguous.

Please re-run this command with `-p <spec>` where `<spec>` is one of the following:

rand:0.5.5
rand:0.4.3
rand:0.3.22
Run Code Online (Sandbox Code Playgroud)

但是,我无法使用cargo uninstall. 这些似乎都不起作用:

  • cargo uninstall rand

  • cargo uninstall -- rand:0.4.3

  • cargo uninstall https://github.com/rust-lang/crates.io-index#rand:0.4.3

对于上面的任何命令,我得到:

error: invalid package id specification: <name-of-package-i-specified>
Run Code Online (Sandbox Code Playgroud)

这似乎是一个相当基本的操作,所以我怀疑它是如何cargo-uninstall使用的基础。

任何指针?

Jan*_*dec 7

cargo uninstall取消 的效果cargo install。你没有cargo install rand,因为它只是一个库,而不是一个可执行程序。这意味着它没有安装

~/.cargo/registry只是构建依赖项的缓存。随时擦拭; 货物将重新下载并重新构建它需要的任何东西。

是的,这是错误的。货物应使用.local.config.cache视情况而定;那么很明显你可以清理什么。在当今时代,使用任意点目录是一种侮辱。据报道,可能有好几次。还没有人来修复它。