cargo: Cargo can't find git credentials for private repo anymore
I was using private repos in my Cargo.toml before without problems. My git installation is GitHub Desktop for windows. But now I get this error when doing cargo build on a project that uses a private repo:
failed to authenticate when downloading repository
attempted to find username/password via git's `credential.helper` support, but failed
Caused by:
[7/-1] Config value 'credential.helper' was not found
Even though ssh-agent.exe is running, and when I git clone the repo manually on the cmd line, it doesn’t ask me for credentials, so the underlying mechanism is working.
(It’s been several months since I last tried to build this project but I didn’t change anything in it from when it last compiled successfully, only updated rust/cargo (and GitHub updated itself).)
cargo 0.16.0-nightly (3568be9 2016-11-26)
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 8
- Comments: 28 (8 by maintainers)
I’m experiencing this too on macOS. It happens with private repos with restricted access. I’m able to git clone those repos without problems using the git command directly, but
cargo updatedoesn’t work:failed to acquire username/password from local configuration.Edit: In my case,
git config --global credential.helper osxkeychainmade it work.I’ve got this now:
git config --global credential.helper "store --file <my credentials>"Notes:
credential.helper 'cache'works in Cargo and it works from thegitcommand line (outside of cargo)credential.helper 'store'works from thegitcommand line (outside of cargo) but fails in Cargohttps, nosshI’m getting the same error again, even though it was working after I had installed pageant.
Why isn’t it working anymore?
I’m using this format in Cargo.toml:
Do I have to write it differently now? Like this?:
But then cargo complains about invalid manifest because of the
:. And when I use/instead, it gives the same error as above…I have GitHub Desktop: Chocolate-Covered Yaks (3.3.4.0) 50415df git version 2.11.0.windows.3
Is it because of this? https://github.com/Microsoft/Git-Credential-Manager-for-Windows#notice-experiencing-github-pushfetch-problems
How to fix this?
Can cargo please print more helpful error information about git failure in the future?
@Boscop Try this with https git repo. I had that error and got it working on windows. #5227
git config --global credential.helper managerWorked flawlessly here on my MacBook. Thank you very much!
I solved it on Mac by installing third-party (Microsoft) credential-manager
Here is what I did for fixing my
cargo add xxissue:brew install cargo-editurl "git@github.com:"andurl "ssh://git@github.com/"sections in~/.gitconfigIn my case, I had this snippet in my
~/.gitconfig—I had to get rid of that. Then the error stopped happening for me.