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 add no longer works with Git using SSH in 0.8.0 #515

Closed
frxstrem opened this issue Sep 23, 2021 · 8 comments
Closed

cargo add no longer works with Git using SSH in 0.8.0 #515

frxstrem opened this issue Sep 23, 2021 · 8 comments
Labels

Comments

@frxstrem
Copy link

frxstrem commented Sep 23, 2021

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:

  1. Install cargo-edit version 0.8.0.
  2. Run cargo add serde in a clean Rust project. This works without any errors.
  3. Add an SSH key valid for GitHub to ~/.ssh/id_rsa.
  4. Run git config --global [email protected]:.insteadof https://github.com/.
  5. 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.

@epage
Copy link
Collaborator

epage commented Sep 23, 2021

I assume regular cargo commands can successfully interact with the registry?

@epage epage added the bug label Sep 23, 2021
@epage
Copy link
Collaborator

epage commented Sep 23, 2021

Also, could you try with --features vendored-libgit2?

@frxstrem
Copy link
Author

frxstrem commented Sep 24, 2021

@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.

@dungph
Copy link

dungph commented Sep 24, 2021

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

@ordian
Copy link
Collaborator

ordian commented Sep 24, 2021

This is a regression introduced in #484. Opened frewsxcv/rust-crates-index#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.

@epage
Copy link
Collaborator

epage commented Sep 24, 2021

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.

@epage
Copy link
Collaborator

epage commented Sep 24, 2021

Looks like we need to be tracking frewsxcv/rust-crates-index#37

@nyurik
Copy link

nyurik commented Dec 17, 2021

The best workaround I found for this:

cargo update && cargo upgrade --offline

Seems to be working well because cargo update downloads the updated index.

@ordian ordian mentioned this issue Jan 27, 2022
nyurik added a commit to nyurik/proj that referenced this issue Feb 25, 2022
Upgrade all proj-sys and proj dependency versions to the latest. For consistency all versions are fully-specified. The only exception is the [approx](https://crates.io/crates/approx) lib because the trait is implemented upstream in `geo-types`. Perhaps if we change geo-types to use `approx = "*"`, it could work?

It is fairly easy to upgrade them now using [cargo upgrade](https://lib.rs/crates/cargo-edit). I usually run it in offline mode due to an [issue](killercup/cargo-edit#515 (comment))

```
cargo update && cargo upgrade --offline --workspace
```
bors bot added a commit to georust/proj that referenced this issue Feb 25, 2022
116: Upgrade dependencies except "approx" r=frewsxcv a=nyurik

Upgrade all proj-sys and proj dependency versions to the latest. For consistency all versions are fully-specified. The only exception is the [approx](https://crates.io/crates/approx) lib because the trait is implemented upstream in `geo-types`. Perhaps if we change geo-types to use `approx = "*"`, it could work?

It is fairly easy to upgrade them now using [cargo upgrade](https://lib.rs/crates/cargo-edit). I usually run it in offline mode due to an [issue](killercup/cargo-edit#515 (comment))

```
cargo update && cargo upgrade --offline --workspace
```

Co-authored-by: Yuri Astrakhan <[email protected]>
@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants