Cargo: 貨物がプライベートgitlabリポジトリコードを取得し、git-credentialsストアで失敗しました

作成日 2019年11月18日  ·  3コメント  ·  ソース: rust-lang/cargo

問題

Cargoがプライベートgitlabリポジトリコードを取得できませんでした。git-credentialsが機能しません。cargo.tomlにユーザー名/パスワードを書き込んでも問題ありません。

_git-資格情報が機能しない_

$ cat ~/.gitconfig
[credential]
        helper = store

$ cat ~/.git-credentials
http://tensorchen:[email protected]

$ cat Cargo.toml
[package]
name = "xxxxx"
version = "0.1.0"
edition = "2018"

[dependencies]
l5 = {git = "http://git.code.oa.com/birdio/l5-rs", branch = "master"}

$ cargo build 
    Updating git repository `http://git.code.oa.com/birdio/l5-rs`
warning: spurious network error (2 tries remaining): failed to receive HTTP 200 response: got 401; class=Net (12)
warning: spurious network error (1 tries remaining): failed to receive HTTP 200 response: got 401; class=Net (12)
error: failed to load source for a dependency on `l5`

Caused by:
  Unable to update http://git.code.oa.com/birdio/l5-rs

Caused by:
  failed to fetch into /root/.cargo/git/db/l5-rs-56b3f1291d851527

Caused by:
  failed to receive HTTP 200 response: got 401; class=Net (12)

_cargo.tomlにユーザー名/パスワードを書き込んでも大丈夫です_

$ cat Cargo.toml
[dependencies]
l5 = {git = "http://tensorchen:[email protected]/birdio/l5-rs", branch = "master"}

$ cargo build 
Updating git repository `http://tensorchen:[email protected]/birdio/l5-rs`
   Compiling l5 v0.1.0 (http://tensorchen:[email protected]/birdio/l5-rs#39fffd34)
   Compiling rust-by-example v0.1.0 (/root/git.code.oa.com/tensorchen/rust-by-example)
    Finished dev [unoptimized + debuginfo] target(s) in 0.52s

ノート

$ cargo version
cargo 1.39.0 (1c6ec66d5 2019-09-30)
$ git version
git version 2.23.0


A-git C-bug

最も参考になるコメント

この問題を解決します

$ cat ~/.cargo/config
[net]
git-fetch-with-cli = true

全てのコメント3件

また、特にプライベートの錆の依存関係のためにCIジョブ内で認証をセットアップしようとすると、この問題に遭遇することがよくあります。 ~/.git-credentialsトリックを使用するのではなく、ユーザーのデフォルトのgit資格情報を継承するカーゴのモードがあると非常に便利です。

この問題を解決します

$ cat ~/.cargo/config
[net]
git-fetch-with-cli = true

この問題を解決します

$ cat ~/.cargo/config
[net]
git-fetch-with-cli = true

この答えをどうもありがとう!!!
さらに、 Cargoの構成は$CARGO_HOME/configです。 これは、カスタム$ CARGO_HOMEを設定する場合に問題になる可能性があります。

$ CARGO_HOME / config。デフォルトは次のとおりです。
Windows:%USERPROFILE%.cargo \ config
Unix:$ HOME / .cargo / config

このページは役に立ちましたか?
0 / 5 - 0 評価