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 https://github.com/google/protobuf
warning: spurious network error (2 tries remaining): failed to connect to github.com: 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
[core]
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.

2 Likes

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

config it is ok!thanks!
[net]
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:

[http]
proxy = "localhost:<PORT>"

[https]
proxy = "localhost:<PORT>"

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

[source.crates-io]
replace-with = 'ustc'

[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"

[http]
multiplexing = false

[net]
retry = 5 # network retries
git-fetch-with-cli = true
2 Likes

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.


这个问题最好去rustcc提问
毕竟这不是一个外国人有可能理解的问题。

以及,你这个网速,我相当建议你试一下nginx本地反代
有问题可以在知乎的评论区提问(github我不会搞评论区)