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

Created on 15 Jul 2019  ·  6Comments  ·  Source: rust-lang/cargo

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.

A-git C-bug O-windows

Most helpful comment

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

All 6 comments

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)?

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

I have updated my proxy, cargo works well.

Thanks @ehuss

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

Thanks @singlewind :)

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
[email protected]
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
[email protected]:.insteadof=https://github.com/
url.https://15b1acb3d21ebde45e8ab271e72fb4b75ad40143:[email protected]/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
[email protected]: 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

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

[url "[email protected]:"]
    insteadOf = https://github.com/
Was this page helpful?
0 / 5 - 0 ratings