cargo-edit
cargo-edit copied to clipboard
`cargo add` no longer works with Git using SSH in 0.8.0
I've configured Git to use SSH by default for all GitHub URLs, including HTTPS, which the command:
$ git config --global [email protected]:.insteadof https://github.com/
which will replace the prefix https://github.com/
with [email protected]:
in all git URLs.
This works perfectly fine when pulling the crates.io index with Git:
$ git clone https://github.com/rust-lang/crates.io-index --depth=1
Cloning into 'crates.io-index'...
remote: Enumerating objects: 85891, done.
remote: Counting objects: 100% (85891/85891), done.
remote: Compressing objects: 100% (38459/38459), done.
Receiving objects: 100% (85891/85891), 39.48 MiB | 11.68 MiB/s, done.
remote: Total 85891 (delta 44780), reused 74962 (delta 37395), pack-reused 0
Resolving deltas: 100% (44780/44780), done.
Updating files: 100% (67956/67956), done.
But it does not work when running cargo add
:
$ cargo add --version
cargo-add 0.8.0
$ cargo add serde
Updating 'https://github.com/rust-lang/crates.io-index' index
Command failed due to unhandled error: authentication required but no callback set; class=Ssh (23); code=Auth (-16)
Steps to reproduce:
- Install
cargo-edit
version 0.8.0. - Run
cargo add serde
in a clean Rust project. This works without any errors. - Add an SSH key valid for GitHub to
~/.ssh/id_rsa
. - Run
git config --global [email protected]:.insteadof https://github.com/
. - Repeat step 2, which now fails with the error above.
I'm unable to reproduce the issue with version 0.7.0, so this seems to have been broken with the release of 0.8.0.
I assume regular cargo commands can successfully interact with the registry?
Also, could you try with --features vendored-libgit2
?
@epage Yes, regular cargo commands can interact with the registry just fine. They also seem to respect the git
configuration (for example, they'll fail if it's misconfigured).
I tried running cargo install cargo-edit --features vendored-libgit2
, after which cargo add
still did not work and gave the same error as before.
cargo add
failed in my machine with message Command failed due to unhandled error: invalid version 0 on git_proxy_options; class=Invalid (3)
but work fine when I install it with cargo install cargo-edit --features vendored-libgit2
This is a regression introduced in #484. Opened https://github.com/frewsxcv/rust-crates-index/issues/65 upstream.
cargo add failed in my machine with message Command failed due to unhandled error: invalid version 0 on git_proxy_options; class=Invalid (3) but work fine when I install it with cargo install cargo-edit --features vendored-libgit2
That's a separate issue, see #510.
In part, I'm tempted t revert #484. On the other hand, I'm unsure how much to worry about cargo add
(though this also impacts cargo upgrade
) because cargo add
is going to need to be rewritten anyways when we upstream it into cargo
.
Looks like we need to be tracking https://github.com/frewsxcv/rust-crates-index/issues/37
The best workaround I found for this:
cargo update && cargo upgrade --offline
Seems to be working well because cargo update
downloads the updated index.