如何使 gitconfig 的 ReplaceOf 与 Cargo 一起使用?

d33*_*tah 2 git rust rust-cargo

我的 ~/.gitconfig 中有以下内容:

[url "git@github.com:"]
       pushInsteadOf = https://github.com/
       insteadOf = https://github.com/
Run Code Online (Sandbox Code Playgroud)

不幸的是,今天我发现这阻止了我cargo build为我制作下载依赖项:

    Updating crates.io index
error: failed to get `libc` as a dependency of package `hilbert-c2rust v0.1.4 (/home/d33tah/workspace/profound/hilbert-c2rust)`

Caused by:
  failed to load source for dependency `libc`

Caused by:
  Unable to update registry `https://github.com/rust-lang/crates.io-index`

Caused by:
  failed to fetch `https://github.com/rust-lang/crates.io-index`

Caused by:
  failed to authenticate when downloading repository
attempted ssh-agent authentication, but none of the usernames `git` succeeded

Caused by:
  no authentication available
Run Code Online (Sandbox Code Playgroud)

这个问题有解决方法吗?暂时注释掉这些行会有所帮助,但我想保留它们,因为它们为我解决了与 Github 相关的问题。

Mar*_*ček 5

将环境变量 CARGO_NET_GIT_FETCH_WITH_CLI 设置为 true。

  • 导出 CARGO_NET_GIT_FETCH_WITH_CLI=true (2认同)

小智 5

试试这个(从这里):

[url "ssh://git@github.com/"]
    insteadOf = https://github.com

[url "https://github.com/rust-lang/crates.io-index"]
    insteadOf = https://github.com/rust-lang/crates.io-index
Run Code Online (Sandbox Code Playgroud)