“Cargo.lock 中的包 foo 被拉入注册表”是什么意思?

blu*_*ray 8 rust

我试图使用ripgrep_all安装cargo install ripgrep_all。它给出了以下错误:

% cargo install ripgrep_all
    Updating crates.io index
  Installing ripgrep_all v0.9.6
error: failed to compile `ripgrep_all v0.9.6`, intermediate artifacts can be found at `/tmp/cargo-install5HlOMt`

Caused by:
  failed to select a version for the requirement `cachedir = "^0.1.1"`
  candidate versions found which didn't match: 0.3.0, 0.2.0
  location searched: crates.io index
  required by package `ripgrep_all v0.9.6`
Run Code Online (Sandbox Code Playgroud)

然后我搜索了一下,发现

看起来cachedir 已经撤回了0.1.1 版本。

解决方案是:

cargo install --locked ripgrep_all 
Run Code Online (Sandbox Code Playgroud)

我能够成功安装它。然而,在安装过程中它说:

% cargo install --force --locked ripgrep_all
    Updating crates.io index
  Installing ripgrep_all v0.9.6
warning: package `cachedir v0.1.1` in Cargo.lock is yanked in registry `crates.io`, consider running without --locked
warning: package `smallvec v1.4.0` in Cargo.lock is yanked in registry `crates.io`, consider running without --locked
Run Code Online (Sandbox Code Playgroud)

这让我很好奇。Yank在 Rust 世界中意味着什么?

loo*_*ops 5

这意味着该包已被标记为“yanked”。当have package的作者有一个非常令人信服的理由表明根本不应该使用某个版本的包,并且强烈建议不应该使用该包时,通常会这样做。您可以忽略猛拉以--force强制使用猛拉的包,但这通常是一个坏主意:通常猛拉包是有充分理由的。

在您的情况下:被拉出的cachedir0.1.X 版本是一个完全不同的软件包,与新版本的作者不同。旧版本不受维护且无法更新(因为cachedir现在有不同的所有者发布了不同的软件包),因此新所有者cachedir撤回了旧版本。smallvec1.4.0 有一个错误,当与零大小的类型一起使用时,它会导致未定义的行为,并且 UB 非常糟糕,以至于您实际上不太可能想要使用该版本。smallvec解决此问题的方法是更新到没有该错误的更高版本。

  • 我发现 https://github.com/rust-lang/crates-io-cargo-teams/issues/9 非常有用。但是,我发现“--locked”也可以代替“--force”。但不确定这两个参数实际上是做什么的。 (2认同)