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 fails when git is configured to use SSH for github.com #3900

Closed
jimmycuadra opened this issue Apr 5, 2017 · 8 comments
Closed

Comments

@jimmycuadra
Copy link
Contributor

Trying to build a Rust program on Circle CI:

cargo test -v
    Updating registry `https://github.com/rust-lang/crates.io-index`
warning: spurious network error (2 tries remaining): [12/-12] Malformed URL 'ssh://[email protected]:/rust-lang/crates.io-index'
warning: spurious network error (1 tries remaining): [12/-12] Malformed URL 'ssh://[email protected]:/rust-lang/crates.io-index'
error: failed to fetch `https://github.com/rust-lang/crates.io-index`

Caused by:
  [12/-12] Malformed URL 'ssh://[email protected]:/rust-lang/crates.io-index'

cargo test -v returned exit code 101

I'd never seen this error before, but I found this blog post (not English, but you can get the gist): https://andelf.github.io/blog/2016/11/18/circleci-meets-rust/

In case that link 404s, the issue is that Circle CI has something in ~/.gitconfig that configures Git to use the SSH protocol for connections to github.com. The workaround recommended in the blog post is to use sed in a previous build step to make the line a no-op:

sed -i 's/github/git-non-exist-hub/g' ~/.gitconfig

Is there something Cargo can do to mitigate this?

This is the closest Cargo issue I could find is #2845. Not sure if it's related.

@alexcrichton
Copy link
Member

Historically issues with Circle CI and Rust have boiled down to #1851, so maybe this is just a dupe of that?

@est31
Copy link
Member

est31 commented Apr 10, 2017

I'm not really sure, but it seems that this is more of a libgit2 issue than a cargo issue.

The relevant cargo code seems to be this. From the output we see that the url it talks about is the https one.

In the fetch call, the url is not changed, but given directly to the git2 crate, which is only a wrapper over libgit2.

Also, while the string "Malformed URL" doesn't appear in the cargo codebase, it does in the libgit2 one.

AFAIK it is possible to compile libgit2 without ssh support. Maybe that's what Circle CI has done, and now libgit2 considers the ssh url as malformed?

@est31
Copy link
Member

est31 commented Apr 10, 2017

Yup, I can't reproduce.

I've added this to .gitconfig (like described in #2845):

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

and doing cargo build I got:

    Updating registry `https://github.com/rust-lang/crates.io-index`
error: failed to load source for a dependency on `git2`

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

To learn more, run the command again with --verbose.

This is not the error message from above.
Then, after ssh-adding my key, I did cargo build again, and it worked. So its very likely that circleCI's copy of libgit2 doesn't have ssh support.

@alexcrichton
Copy link
Member

Cargo statically links libgit2 so this may not be related to the version on Circle CI I think? My guess is it's the colon after github.com in the URL, that's invalid but I'm not sure where it's coming from.

@est31
Copy link
Member

est31 commented Apr 10, 2017

My guess is it's the colon after github.com in the URL, that's invalid but I'm not sure where it's coming from.

Yup seems you are right with your guess. According to this post (apparently by a person with the same issue), the gitconfig looks like:

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

Note the missing / in comparison to the gitconfig entry I had above. Setting it makes me reproduce the issue. Git cloning it works out of some weird reason though, this is why I earlier thought the URL was valid.

@alexcrichton
Copy link
Member

@est31 oh interesting! Can you clarify the behavior of with-and-without-trailing slash? With it you're getting #2845? (circleci doesn't use ssh-agent, we don't parse ~/.ssh/config for keys on the filesystem). Without it you get the error in the OP?

@est31
Copy link
Member

est31 commented Apr 10, 2017

Can you clarify the behavior of with-and-without-trailing slash?

This comment describes the behaviour for me with insteadOf = https://github.com/, generating an url ssh://[email protected]:rust-lang/crates.io-index: #3900 (comment)

The behaviour for me with insteadOf = https://github.com, generating an url ssh://[email protected]:/rust-lang/crates.io-index is consistent with what @jimmycuadra reported.

I never got #2845.

grafi-tt added a commit to grafi-tt/system-programming-rust that referenced this issue Apr 19, 2017
jbg added a commit to jbg/bitcoin-consensus that referenced this issue May 21, 2017
@alexcrichton
Copy link
Member

I'm going to close this in favor of #2078 as I believe that's the root cause here.

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

No branches or pull requests

3 participants