Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make gitconfig's InsteadOf work with Cargo?

I have the following in my ~/.gitconfig:

[url "[email protected]:"]
       pushInsteadOf = https://github.com/
       insteadOf = https://github.com/

Unfortunately today I discovered that this prevents me from making cargo build download dependencies for me:

    Updating crates.io index
error: failed to get `libc` as a dependency of package `hilbert-c2rust v0.1.4 (/home/d33tah/workspace/profound/hilbert-c2rust)`

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

Caused by:
  Unable to update registry `https://github.com/rust-lang/crates.io-index`

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

Caused by:
  failed to authenticate when downloading repository
attempted ssh-agent authentication, but none of the usernames `git` succeeded

Caused by:
  no authentication available

Is there a workaround for this problem? Commenting out the lines temporarily helps, but I'd like to keep them because they solve a problem related to Github for me.

like image 626
d33tah Avatar asked Mar 02 '23 07:03

d33tah


2 Answers

Set env var CARGO_NET_GIT_FETCH_WITH_CLI to true.

like image 58
Martin Cifko Štefček Avatar answered Mar 05 '23 14:03

Martin Cifko Štefček


Try this (from here):

[url "ssh://[email protected]/"]
    insteadOf = https://github.com

[url "https://github.com/rust-lang/crates.io-index"]
    insteadOf = https://github.com/rust-lang/crates.io-index
like image 33
vvxhid Avatar answered Mar 05 '23 15:03

vvxhid