When I add the following dependencies to cargo.toml, Cargo uses the global Git proxy to download them. However, even when I set a local proxy for a specific project, Cargo still uses the global proxy. This is not the expected behavior.
I need to set up different proxies for different projects. Aside from changing the global proxy when switching projects, I’m wondering if there are any other solutions.
how did you configure the proxy for your projects? is it through git config file or environment variable? there are multiple sources of proxy settings that git could use.
for example, what's in your ~/.gitconfig? and, what's the value of environment variable HTTPS_PROXY?
Maybe libgit2 doesn't read that config? Try using the net.git-fetch-with-cli cargo config. Or maybe specifying the proxy in the http section also works for libgit2?
I have tested both scenarios: using git-cli and not using git-cli. When the git-fetch-with-cli option is enabled in Cargo, the proxy set via --local does not take effect, while proxies set via --system and --global do take effect.
[net]
git-fetch-with-cli=true
If the git-fetch-with-cli option is not enabled, create a %project_home%/.cargo/config.toml file in your project directory and use the following options to configure different proxies for different projects.