Skip to content

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

Open
@LukeMathWalker

Description

Problem

It is fairly common for a Rust user to assume that the URL you get from GitHub to clone a repository (e.g. git@github.com: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://git@github.com:{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 git@github.com:{org_name}/{repo_name}.git to ssh://git@github.com/{org_name}/{repo_name}.git).

Notes

No response

Version

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Error and warning messages generated by Cargo itself.A-gitArea: anything dealing with gitC-bugCategory: bugS-needs-mentorStatus: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions