Rust build git fetch used https

I want use ssh instead of https.

[root@VM-24-3-centos tiflash-proxy]# cargo build --no-default-features --features ' portable sse test-engines-rocksdb cloud-aws cloud-gcp cloud-azure' --release -Z build-std=core,std,alloc,proc_macro,test --target=x86_64-unknown-linux-gnu -Z unstable-options --out-dir=target/release
Updating git submodule
warning: spurious network error (2 tries remaining): failed to connect to Connection timed out; class=Os (2)

my ~/.gitconfig had config it!
[url "git://"]
insteadOf = https://

but under rust dir, there is not config git instead of https
[root@VM-24-3-centos .cargo]# cat /root/.cargo/git/checkouts/rust-protobuf-6d53d5b5de89008a/6642eba/google-protobuf/.git/config
bare = false
repositoryformatversion = 0
filemode = true
logallrefupdates = true

maybe you need an HTTPS proxy?


Actually, you could execute git clone manyally, and edit the Cargo.toml to relocate the git:// to the local folder after git clone is finished.

I had config Cargo.toml,but also fail

It seems that something on your system or network is preventing the connection with github. Do you have a proxy or firewall that is blocking it?

why not using path = variable for protobuf ?
you could modify all github related Cargo.toml since you already obtained them from github.

Yes, it's administratively imposed and they don't have access to an unfiltered connection.

We should be shipping tools that don't need live GitHub access.

1 Like

You can try following the guide at Appendix: Git Authentication - The Cargo Book for how to set up ssh authentication. And if that doesn't work it suggest using the net.git-fetch-with-cli config to use git's cli for fetching repos instead of libgit2. Also I think you shouldn't pretend to be github, but rather mirror them to your own server and then point cargo to this server.


I can clone https://XXX,but rust build still failed。(Although I config credential)

config it is ok!thanks!
git-fetch-with-cli = true

1 Like

because the rust repo is my submodule,I can't change it

but still build fail!I had config .cargo/config (source.crates-io)

did you try adding in ~/.cargo/config:

proxy = "localhost:<PORT>"

proxy = "localhost:<PORT>"

this is my config, don't know whether it works for you.

replace-with = 'ustc'

registry = "git://"

multiplexing = false

retry = 5 # network retries
git-fetch-with-cli = true

It can run, but it will eventually hang. (After 12 hours to check, only 7% progress)

This should be a Chinese only problem.

Thus the reply is written in Chinese.