Skip to content
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

cargo can't fetch crates.io-index on windows #7138

Closed
smallnest opened this issue Jul 15, 2019 · 10 comments
Closed

cargo can't fetch crates.io-index on windows #7138

smallnest opened this issue Jul 15, 2019 · 10 comments
Labels
A-git Area: anything dealing with git C-bug Category: bug O-windows OS: Windows

Comments

@smallnest
Copy link

Problem

install the latest nightly rust and add rocket = "0.4.2" in dependency.

run cargo run but can't fetch cargo.index. The error log as below:

C:\rustt>cargo run
    Updating crates.io index
error: failed to load source for a dependency on `rocket`

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 start SSH session: socket disconnect; class=Ssh (23)

environment
0、 windows 10/git2.22.0.1/TortoiseGit 2.8.0.0 (use openSSH)

1、cargo -version

c:> cargo --version
cargo 1.38.0-nightly (677a180f4 2019-07-08)

2、rustup show

C:\>rustup show
Default host: x86_64-pc-windows-msvc

installed toolchains
--------------------

stable-x86_64-pc-windows-msvc
nightly-x86_64-pc-windows-msvc (default)

active toolchain
----------------

nightly-x86_64-pc-windows-msvc (default)
rustc 1.38.0-nightly (83e4eed16 2019-07-14)

It is normal on my Mac.

@smallnest smallnest added the C-bug Category: bug label Jul 15, 2019
@ehuss
Copy link
Contributor

ehuss commented Sep 21, 2019

Hi @smallnest, I'm sorry nobody responded to your issue. Are you still able to reproduce this issue with the latest nightly version of cargo? I've been unable to find a way to get it to happen, and I'm a bit confused why it is trying to start an SSH session for an https url.

If you can still reproduce it, can you copy your git configuration (git config --list, remove any sensitive values if any)?

@ehuss ehuss added A-git Area: anything dealing with git O-windows OS: Windows labels Sep 21, 2019
@smallnest
Copy link
Author

I think it should be caused by my proxy.
It is not cargo problem.

I have updated my proxy, cargo works well.

Thanks @ehuss

@singlewind
Copy link

singlewind commented Sep 24, 2019

I've exactly the same issue. I reckon it was related the powershell hijack ssh keyword.

[Update]
I was wrong. It was not powershell try to alias ssh. I've OpenSSH installed. However, this doesn't contribute to the issue I think.

I have created a config file at CARGO_HOME with the content below fix this issue

[net]  
git-fetch-with-cli = true

@kasvith
Copy link

kasvith commented Nov 9, 2019

Thanks @singlewind :)

@henryas
Copy link

henryas commented May 11, 2020

Hi,
I have the same issue. It's been a while since I worked with Rust and it used to run just fine. When I return a few days ago, and try to cargo build, I got the same error:

    Updating crates.io index
error: failed to get `rusqlite` as a dependency of package `xxx v0.1.0 (C:\Users\xxx\Documents\Projects\Rust\xxx)`

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

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 start SSH session: socket disconnect; class=Ssh (23)

I am running on Windows 10.

Here is my git config:

http.sslbackend=schannel
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
credential.helper=manager
core.autocrlf=true
core.fscache=true
core.symlinks=true
user.name=xxx
user.email=xxx@users.noreply.github.com
core.autocrlf=true
core.excludesfile=C:\Users\xxx\Documents\gitignore_global.txt
core.editor="C:\Users\xxx\AppData\Local\Programs\Microsoft VS Code\Code.exe" --wait
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.required=true
http.cookiefile=C:\Users\xxx\.gitcookies
difftool.sourcetree.cmd='' "$LOCAL" "$REMOTE"
mergetool.sourcetree.cmd=''
mergetool.sourcetree.trustexitcode=true
url.git@github.com:.insteadof=https://github.com/
url.https://15b1acb3d21ebde45e8ab271e72fb4b75ad40143:x-oauth-basic@github.com/xxx.insteadof=https://github.com/xxxx
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true

When I tried @singlewind 's solution, I got this error:

error: failed to get `rusqlite` as a dependency of package `xxx v0.1.0 (C:\Users\xxx\Documents\Projects\Rust\xxx)`

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

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:
  process didn't exit successfully: `git fetch --tags --force --update-head-ok https://github.com/rust-lang/crates.io-index refs/heads/master:refs/remotes/origin/master` (exit code: 128)
--- stderr
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

On the other hand, I can still use git to fetch and push my repositories at github with no problem.

Any idea what's going on? Any possible solutions?

Thanks.

Henry

@henryas
Copy link

henryas commented May 11, 2020

I found the solution. In my case, I have to change my .gitconfig file and comment out the following:

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

@Mellbourn
Copy link

Is there any other workaround? I like having insteadOf in .gitconfig. Can I give a parameter cargo install instead?

@ehuss
Copy link
Contributor

ehuss commented Feb 13, 2021

@Mellbourn There is a workaround noted in #8172 (comment).

@Latimus
Copy link

Latimus commented Feb 15, 2023

Use sudo

@ivikasavnish
Copy link

I found the solution. In my case, I have to change my .gitconfig file and comment out the following:

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

Worked for me also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-git Area: anything dealing with git C-bug Category: bug O-windows OS: Windows
Projects
None yet
Development

No branches or pull requests

8 participants