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

Confusing error message when using GitHub's SSH URL #13549

Open
LukeMathWalker opened this issue Mar 6, 2024 · 7 comments
Open

Confusing error message when using GitHub's SSH URL #13549

LukeMathWalker opened this issue Mar 6, 2024 · 7 comments
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. A-git Area: anything dealing with git C-bug Category: bug S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.

Comments

@LukeMathWalker
Copy link

LukeMathWalker commented Mar 6, 2024

Problem

It is fairly common for a Rust user to assume that the URL you get from GitHub to clone a repository (e.g. [email protected]:rust-lang/cargo.git for Cargo) should be a valid value for the git field in a dependency or when doing cargo install --git <URL>.

It isn't, and that's OK.
But we also don't nudge the user in the right direction.

The first error they get is:

error: invalid url `<URL>`: relative URL without a base

If they figure out they need to add ssh:// in front, the error becomes:

error: invalid url `ssh://[email protected]:{org_name}/{repo_name}.git`: invalid port number

because the org name is interpreted as a port number (which isn't obvious from the error message, since it doesn't say what is being picked up as port number).

Steps

No response

Possible Solution(s)

I'd love to see better diagnostics from cargo on this.
If the format of the URL matches what GitHub provides, we should be able to suggest the correct value (i.e. from [email protected]:{org_name}/{repo_name}.git to ssh://[email protected]/{org_name}/{repo_name}.git).

Notes

No response

Version

No response

@LukeMathWalker LukeMathWalker added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Mar 6, 2024
@epage epage added the A-git Area: anything dealing with git label Mar 6, 2024
@epage
Copy link
Contributor

epage commented Mar 6, 2024

I remember us having a PR that did some special logic for github, improving error messages I think. Unfortunately, searching for "github" on github doesn't return a lot of quality results.

@LukeMathWalker
Copy link
Author

I tried searching as well before opening the issue, but nothing came up as duplicate/highly-related.

@ehuss
Copy link
Contributor

ehuss commented Mar 6, 2024

I'm a little confused, as I'm uncertain why this would be specific to GitHub? The [email protected]:rust-lang/cargo.git is just a normal git SSH shorthand, it works with any host.

(If we bother to add a parser for it, we should probably just support the shorthand à la #1851.)

@ehuss
Copy link
Contributor

ehuss commented Mar 6, 2024

Oh, btw, we added ssh shorthand support for submodules in #7238.

@LukeMathWalker
Copy link
Author

I'm a little confused, as I'm uncertain why this would be specific to GitHub?

It's not specific to GitHub, but I'm assuming that's the reason most people run into this issue.

@LukeMathWalker
Copy link
Author

I'm also not an expert in SSH formats 😅

@weihanglo weihanglo added S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing. A-diagnostics Area: Error and warning messages generated by Cargo itself. and removed S-triage Status: This issue is waiting on initial triage. labels Mar 29, 2024
@weihanglo
Copy link
Member

I'd like to see some improvements on it, specifically the first one error: invalid url : relative URL without a base.

Though I don't really have time thinking hard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. A-git Area: anything dealing with git C-bug Category: bug S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.
Projects
None yet
Development

No branches or pull requests

4 participants