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

Cannot use cargo uninstall to uninstall packages in ~/.cargo: package id specification matched no package

我无法从系统中卸载 Cargo 安装的软件包。

$HOME/.cargo

下明显安装了像rand-0.3.22这样的包
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/

这也可以通过使用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

但是,我无法使用 cargo uninstall 删除该软件包。 None 这些似乎有效:

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

error: invalid package id specification: <name-of-package-i-specified>

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

有什么指点吗?

cargo uninstall 撤销 cargo install 的效果。你没有cargo installrand,因为它只是一个库,不是可执行程序。这意味着它未安装

~/.cargo/registry 只是构建依赖项的缓存。随时擦拭; cargo 将在需要时重新下载并重新构建所需的任何内容。

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