Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cargo is incompatible with the insteadOf URL rewriting of git-config(1) #10203

Closed
Gottox opened this issue Dec 16, 2021 · 1 comment
Closed
Labels
C-bug Category: bug

Comments

@Gottox
Copy link

Gottox commented Dec 16, 2021

Problem

I'm using git's URL rewrite feature to force git pulls/pushes to be established via ssh instead of http(s). This allows me to define git submodules to be defined as http and still benefit from from all the ssh features. Unfortunately, this breaks cargo as described below:

Steps

  1. Set git config:
$ git config --global 'url.git+ssh://git@ssh.github.com:443/.insteadOf' https://github.com/
  1. create a new project:
$ cargo init /tmp/test-project && cd /tmp/test-project
  1. add a dependency to Cargo.toml. For example serde:
$ echo 'serde = "*"' >> Cargo.toml
  1. Run cargo update
$ cargo update
    Updating crates.io index
warning: spurious network error (2 tries remaining): unknown scheme for URL 'git+ssh://git@github.com/rust-lang/crates.io-index'; class=Net (12); code=InvalidSpec (-12)
warning: spurious network error (1 tries remaining): unknown scheme for URL 'git+ssh://git@github.com/rust-lang/crates.io-index'; class=Net (12); code=InvalidSpec (-12)
error: failed to get `serde` as a dependency of package `test-project v0.1.0 (/tmp/test-project)`

Caused by:
  failed to load source for dependency `serde`

Caused by:
  Unable to update registry `crates-io`

Caused by:
  failed to fetch `https://github.com/rust-lang/crates.io-index`

Caused by:
  network failure seems to have happened
  if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
  https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli

Caused by:
  unknown scheme for URL 'git+ssh://git@github.com/rust-lang/crates.io-index'; class=Net (12); code=InvalidSpec (-12)

Possible Solution(s)

No response

Notes

As a workaround to this issue on can set CARGO_NET_GIT_FETCH_WITH_CLI=true.

Version

$ cargo version --verbose 
cargo 1.58.0-nightly (294967c53 2021-11-29)
release: 1.58.0
commit-hash: 294967c53f0c70d598fc54ca189313c86c576ea7
commit-date: 2021-11-29
host: x86_64-unknown-linux-gnu
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:OpenSSL/1.1.1l)
os: Linux Rolling Release (void) [64-bit]
@Gottox Gottox added the C-bug Category: bug label Dec 16, 2021
@alexcrichton
Copy link
Member

I believe that this is a duplicate of #2078, so I'm going to close in favor of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants