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

Cannot parse "scp-style" git URLs #3014

Closed
nipunn1313 opened this issue Aug 18, 2016 · 5 comments
Closed

Cannot parse "scp-style" git URLs #3014

nipunn1313 opened this issue Aug 18, 2016 · 5 comments

Comments

@nipunn1313
Copy link
Contributor

[dependencies.myrepo]
git = "[email protected]:repo/myrepo.git"

According to "git help clone" this is a valid url type

       An alternative scp-like syntax may also be used with the ssh protocol:

       o   [user@]host.xz:path/to/repo.git/

However, cargo chokes on this because the url does not parse. I traced this to a call to Url::parse which does not accept this format.

Filed here with rust-url, but it seems that rust-url shouldn't be expected to parse this git format.
servo/rust-url#220

Does libgit2 have a url parsing library?

@alexcrichton
Copy link
Member

Thanks for the report! I believe this is a duplicate of #1851, so I'm going to close in favor of that for now.

I also think that the url crate may strive to be more standards-driven in the sense that it may not ever parse these kinds of URLs. That being said, I'd be totally fine adding that sort of parsing to Cargo, as it seems quite appropriate to add!

For now though you can work around this with a URL of the form:

ssh://[email protected]/path/to/repo.git

@nipunn1313
Copy link
Contributor Author

@alexcrichton that workaround is actually not identical.
See jboning's explanation here https://secure.phabricator.com/T11004

If you use the scp-style syntax, it sets your cwd to the user's home directory, while ssh style syntax sets your cwd to the root.

Thus, you can work around with an absolute path using ssh syntax, but it's not 1<->1 the same.

I actually believe #1851 is conflating two separate issues

  1. Manifest parse error on an scp-style git url
    nipunn-mbp:engine nipunn$ cargo build
error: failed to parse manifest at `project/Cargo.toml`

Caused by:
  invalid url `[email protected]:repo/myrepo.git`: relative URL without a base
  1. Inability to fetch ssh credentials without ssh-agent running. The executable git clone seems to look into ~/.ssh/id_rsa in order to do the cloning even if ssh-agent is not running or not authenticated. Seems like cargo (libgit2?) will not work unless ssh-agent is running.

I ran into both issues when investigating this issue on my side. I was running out of a blank lxc container which didn't have ssh-agent running and
First ran into (1) -> switched to ssh url
Ran into issue (2) -> ran eval ssh-agent ; ssh-add
Ran into into the homedir path issue. -> switched to an absolute path

I'd like to reopen this one to pay attention to issue (1) and leave #1851 because it has a lot of conversation about issue (2).

@alexcrichton
Copy link
Member

Aha very good points! I'm also cool leaving this open as a separate issue.

@alexcrichton alexcrichton reopened this Aug 19, 2016
@alexcrichton
Copy link
Member

And yeah to clarify I believe that the git command line tool literally shells out to the ssh command line tool which is why it doesn't require ssh-agent to be running. Cargo, however, links to libgit2 for git operations and libssh2 for ssh operations. Neither implements parsing of ~/.ssh/config (#2078) but libssh2 supports ssh-agent, so that's the only source we draw keys from right now.

@alexcrichton
Copy link
Member

I believe this is a duplicate of #1851, so closing in favor of that.

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

2 participants