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 cannot parse azure devops ssh git urls #13622

Closed
juliusl opened this issue Mar 22, 2024 · 3 comments
Closed

Cargo cannot parse azure devops ssh git urls #13622

juliusl opened this issue Mar 22, 2024 · 3 comments
Labels
A-git Area: anything dealing with git C-enhancement Category: enhancement S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.

Comments

@juliusl
Copy link

juliusl commented Mar 22, 2024

I'm running into a bit of trouble trying to get a crate from an azure devops registry.

I am able to run the git command that cargo will eventually call successfully,

❯ git fetch --force --update-head-ok '<omitted>@ssh.dev.azure.com:v3/<omitted>/<omitted>/<my-repo>' '+HEAD:refs/remotes/origin/HEAD'

However, due to this line:

let git_url = self.git.parse::<url::Url>()?;

I get the error:

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

I've tried several variations of the url, but that format seems to be the only one that works. The recommendation from the cargo book does not work and returns this error:

 git fetch --force --update-head-ok 'ssh://<omitted>@ssh.dev.azure.com/<omitted>/<omitted>/<my-repo>.git' '+HEAD:refs/remotes/origin/HEAD'
remote: Command git-upload-pack '/<omitted>/<omitted>/<my-repo>.git' is not in expected format.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Since cargo is able to parse that format, the above error is what I receive when calling cargo update, which circles back to this issue.

Also, if I try to use ssh://<omitted>@ssh.dev.azure.com:v3/<omitted>/<omitted>/<my-repo>, url::Url::parse will return:

invalid url `<omitted>`: invalid port number

Given how nuanced private git repo urls can be, I feel like url::Url might not be the right type at this point and could be refactored w/ a newtype that is more flexible. Would this be open to discussion? (I don't mind contributing this change if a maintainer allows it)

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

epage commented Mar 22, 2024

This looks to be a duplicate of #13549. Does that cover your use case?

@weihanglo
Copy link
Member

also #1851

@weihanglo weihanglo added S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. and removed S-triage Status: This issue is waiting on initial triage. labels Mar 23, 2024
@juliusl
Copy link
Author

juliusl commented Mar 25, 2024

@epage @weihanglo Thanks for the reply. Actually yes, there's a link I found in those issues: https://fahn.co/posts/cargo-auth-for-private-git-repos.html.

I was able to get it to work by changing :v3 to /v3.

@juliusl juliusl closed this as completed Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-git Area: anything dealing with git C-enhancement Category: enhancement S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.
Projects
None yet
Development

No branches or pull requests

3 participants