代码之家  ›  专栏  ›  技术社区  ›  bergercookie Seivan

无法使用cargo uninstall卸载~/。cargo:包id规范与no package匹配

  •  0
  • bergercookie Seivan  · 技术社区  · 6 年前

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

    像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/
    

    这也可以通过使用 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 . 这些似乎都不起作用:

    • 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>
    

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

    有什么线索吗?

    1 回复  |  直到 6 年前
        1
  •  2
  •   Jan Hudec    6 年前

    cargo uninstall 消除 cargo install 货物安装 rand ,因为它只是一个库,而不是一个可执行程序。也就是说 未安装 .

    这个 ~/.cargo/registry 只是生成依赖项的缓存。任何时候都可以随意擦拭;货物会重新下载,并在需要时重新构建。

    是的,这是错误的。货物应使用 .local , .config .cache 如果合适的话,你可以很明显的清理掉。在当今时代,使用任意的点dirs是一种侮辱。据报道,可能有好几次。还没人来修理它。