I'm having a weird issue with trying to connect to Cargo's index registry. When I try and run cargo search maturin -vv from an MSYS2 terminal (with Rust installed) to get Cargo to update its index, I get a connection error:
$ cargo search maturin -vv
Updating crates.io index
warning: spurious network error (3 tries remaining): [56] Failure when receiving data from the peer
(CONNECT tunnel failed, response 403)
warning: spurious network error (2 tries remaining): [56] Failure when receiving data from the peer
(CONNECT tunnel failed, response 403)
warning: spurious network error (1 tries remaining): [56] Failure when receiving data from the peer
(CONNECT tunnel failed, response 403)
error: download of config.json failed
Caused by:
failed to download from `https://index.crates.io/config.json`
Caused by:
[56] Failure when receiving data from the peer (CONNECT tunnel failed, response 403)
When I try and curlhttps://index.crates.io/config.json directly, however, I am able to download the config.json file with no issues. This is a clean Rust + cargo install on MSYS2 with no environment variables or config files set, so I'm not sure what is causing the issue.
UPDATE:
Other commands I've tried, and the errors I'm getting:
$ cargo search anyhow --config CARGO_NET_GIT_FETCH_WITH_CLI=true
error: failed to parse value from --config argument `CARGO_NET_GIT_FETCH_WITH_CLI=true` as a dotted
key expression
Caused by:
TOML parse error at line 1, column 1
|
1 | CARGO_NET_GIT_FETCH_WITH_CLI=true
| ^^
invalid key
Thanks for the quick reply! I ran curl https://index.crates.io/config.json on the same terminal from which I ran cargo search maturin -vv, so would this still apply? This is also not to mention that pip install maturin is able to download the index and crates with no issue, also from the same terminal.
Also CARGO_NET_GIT_FETCH_WITH_CLI=true should be set as env var, so for example CARGO_NET_GIT_FETCH_WITH_CLI=true cargo search anyhow. It only applies to git dependencies and not registry dependencies, so it wouldn't help for your problem anyway.
@bjorn3 , thanks for your reply! I don't have any proxies enabled, as far as I can tell. Within MSYS2, these are the current environment variables I have set up:
As for other forms of potential proxies, our company does run a corporate VPN. I have tried switching that off and running cargo search again, but it still throws up the same spurious network error warning. The only other place left would be my firewall settings, and I will have to speak with the in-house IT team about that.
Maybe CARGO_HTTP_DEBUG=true CARGO_LOG=network=trace cargo search anyhow shows what proxy was used? Be aware of the following warning in the docs for this option though:
Be wary when posting logs from this output in a public location. The output may include headers with authentication tokens which you don’t want to leak! Be sure to review logs before posting them.
Thank you so much for showing me how to enable logging for the Cargo function!
Thanks to you, it turns out that I had set up a separate cargo config.json file in MSYS2's home directory (/c/msys64/home/username/.cargo), not the Windows one (C:\Users\username\.cargo), and it was pointing to a proxy server I had set up earlier. Deleting it allowed cargo search to work as intended.