cargo: Authentication failure with git dependencies via https on Windows (10)

Summary

Cargo fails to load a git dependency over https on Windows because of not finding the credentials via git’s credentials-helper. The credentials are saved in Windows Credentials Manager and a normal git clone works perfectly fine without entering credentials. The problem is not present on Linux using credentials-cache.

What we have tried

  • including a crate from an private repository via https located on a personal Gitlab instance or Bitbucket using cargo with a dependency like pfwr = { git = "https://git.****.****/****/pfwr.git" }
  • using plain text credentials-store in the global .gitconfig instead of the credentials-manager

What we expected

  • cargo should download the dependency from git authenticating via the credential-helper like on Linux when building the project

What happened instead

  • cargo fails to load the source:
> cargo run --verbose
    Updating git repository `https://git.****.****/****/pfwr.git`
error: failed to load source for a dependency on `pfwr`

Caused by:
  Unable to update https://git.****.****/****/pfwr.git

Caused by:
  failed to fetch into C:\Users\****\.cargo\git\db\pfwr-3bec381543b163f9

Caused by:
  failed to authenticate when downloading repository
attempted to find username/password via git's `credential.helper` support, but failed

Caused by:
  an unknown git error occurred
  • plain text credentials in global .gitconfig seems to work on one W8.1 machine, but not on two W10 machines tested on

Cargo version

  • the output of cargo --version on my W10 machine is: cargo 0.25.0 (96d8071da 2018-02-26)

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 21 (10 by maintainers)

Most upvoted comments

I just ran into this problem as well.

Each of the following failed

  • I tried adding Git/bin to path without any luck
  • I tried nightly and that didn’t work either
  • git config --system credential.helper manager did not work

What did work was this

  • git config --global credential.helper manager did work

I undid the other changes before I tried the last one, so that seems to be all that’s needed. So it looks like git in this case is not picking up the system config settings