-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crates.io index update failing due to conflict with ~/.gitconfig #8172
Comments
Oh dear, this looks bad! It may be a bug elsewhere though that is triggering the apparent need for authentication when auth shouldn't be needed. Are you able to clone that url via the git CLI itself? If not, can you try running with |
Sorry for the delay, I'll try your instructions now. |
So I reinstalled my system and now it is working as expected. I'm sorry but now I'm not able to debug and reproduce the error anymore, but thanks for your help. |
After some testing, I think that hiding HOME leads to another errors, as Rust uses the environment variable. |
If you are using SSH authentication, there is some guidance here for how to configure that with Cargo. Cargo doesn't ever ask for a password, so you have to make sure authentication is configured before running Cargo. Additionally, Cargo's built-in SSH library does not use OpenSSH's configuration files. If you have more advanced authentication requirements, I recommend using |
I don't want to use SSH with cargo!, the SSH config present in my .gitconfig file is meant for cloning github repositories. I found this |
@marcospb19 I have a similar setup, for the same reason, but using Here's the configuration you want:
That should solve your problem. |
On Cargo's side, we could have an extra check that asks git2-rs what the repository URL is after it has been mapped via git configuration, and if it's going to use SSH protocol, we can print an additional warning explaining the limitations of using SSH repositories, and suggesting the use of |
@joshtriplett thanks for the response, looks like I don't need to clone the url with SSH protocol, this should work. But still, cargo should check this, it is an existing conflict with valid git user configuration. |
Works for not having to type password on git pushes, but not on git clones if the repository is private. |
@marcospb19 It's possible to configure git to handle authentication for private github repos over https. But if the repository is private, I'd suggest just using an ssh URL to clone it. |
Sometimes I'm browsing my private repositories and I just copy the URL at my browser directly to the terminal, at others I type the HTTP address on the terminal because I memorized it. This is a VALID feature of Git, but Cargo don't consider it, so now I have to always go to the repository link and copy the SSH address that GitHub gives me. With all the respect, I'm not a huge fan of the way you recommend avoiding using a Git feature instead of debating how can we solve the issue, if it is solvable and why. Is there a reason why I should not use this Git feature besides the fact that Cargo has a bug? If this is unsolvable, then I might just accept it and close this issue, at least people that have the same problem can find this issue for reference on how to solve it, because there's actually no clear hints of how to. But I don't think that this is unsolvable (at least a message error advertising the possible reason of the error). |
@marcospb19 Can you clarify what the issue is with setting |
@ehuss, I'm sorry but I have no idea what you're talking about, I'm not trying to authenticate nor configuring anything with cargo and I don't know what is I just tried running this command on my terminal: $ cargo search a And problems occurred as I explained. |
Ah, sorry about the confusion. Cargo needs to communicate with GitHub for the index, and the [net]
git-fetch-with-cli = true Assuming the |
Thanks for your response, there's something I did not understood.
Why would I want this to happen? |
If you want to have a global git configuration that tells git to always use SSH, then there isn't any choice. All tools using git will use that configuration. I think, if for whatever reason you really need to use https for Cargo's index, I think an alternate solution would be to use this in gitconfig: [url "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 I'm not 100% certain that always works, but I did a quick test and it seems ok. |
It seems to me that a reasonable way to solve it is by bypassing the default git config by using the libgit2 machinery that was added here: Issue We probably need to add some plumbing in But in theory after that is done, cargo can finally break free from the dependency on the user's defined default git config. |
I have the same issue on debian testing with rustup. Stable rustc and cargo installed. I get the following error message:
|
The suggested fix from @ehuss worked great. Thanks for that. That said, coming from many other languages or tools (python, ruby, go, etc) and being brand new to rust, this behavior - the error - is completely unexpected. While the error message is more clear having the context of this thread in mind, it certainly was not so when trying to decipher why everything else that uses git authenticates fine, but suddenly I've got something that's saying the auth is missing, or more generally wrong? While staring at the error, contemplating everything that does work re: git, it's very confusing why rust/ While there's probably enough verbiage in the error message, without the additional context that cargo has read something from Ideally, this could be fixed so cargo behaved more like other consumers of Maybe something simple like this when running
|
@ehuss's fix works great for me. I agree with @rjhornsby that at the very least a better message should be printed about the use of Perhaps adding a section on it to The Cargo Book and linking to it, along with the |
EDIT: workaround solution at #8172 (comment).
EDIT: more precise explanation of this bug at #8172 (comment).
While trying to install delta, I got this error:
cargo build --release
I know almost nothing about Rust or Cargo, sorry if this issue isn't very clear.
Why would
cargo
usessh
to make this update?Notes
Cargo and Rust
--version
:1.43.0
OS:
Arch Linux
The text was updated successfully, but these errors were encountered: