fix: add error message for github PR url in dep#15003
fix: add error message for github PR url in dep#15003joshka wants to merge 4 commits intorust-lang:masterfrom
Conversation
Prior to this, using a github PR URL would cause cargo to attempt to
fetch from an incorrect URL several times before failing.
Providing a github pull request url now fails with an error message
that shows how to fix the problem.
E.g.:
```toml
bar = { git = "https://github.com/foo/bar/pull/123" }
```
Now gives the following error message:
```
dependency (bar) specifies a GitHub pull request link. If you were trying to specify a specific github PR, replace the URL with the git URL (e.g. `git = "https://github.com/foo/bar.git"`) and add `rev = "refs/pull/123/head"` in the dependency declaration.
```
Fixes: rust-lang#15001
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @weihanglo (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
weihanglo
left a comment
There was a problem hiding this comment.
Thanks! If needed, we can iterate it later :)
|
I'm not quite sure what the right approach to getting the tests to succeed both in CI and locally for this change. Any guidance? |
tests/testsuite/bad_config.rs
Outdated
| [WARNING] spurious network error (3 tries remaining): unexpected http status code: 404; class=Http (34) | ||
| [WARNING] spurious network error (2 tries remaining): unexpected http status code: 404; class=Http (34) | ||
| [WARNING] spurious network error (1 tries remaining): unexpected http status code: 404; class=Http (34) | ||
| [ERROR] failed to get `bar` as a dependency of package `foo v0.0.0 ([ROOT]/foo)` | ||
|
|
||
| Caused by: | ||
| failed to load source for dependency `bar` | ||
|
|
||
| Caused by: | ||
| Unable to update https://github.com/foo/bar/pull/123 | ||
|
|
||
| Caused by: | ||
| failed to clone into: [ROOT]/home/.cargo/git/db/123-[HASH] | ||
|
|
||
| Caused by: | ||
| network failure seems to have happened | ||
| if a proxy or similar is necessary `net.git-fetch-with-cli` may help here | ||
| https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli | ||
|
|
||
| Caused by: | ||
| unexpected http status code: 404; class=Http (34) |
There was a problem hiding this comment.
Interesting. I thought it was network flakiness. Anyway, you can use ... to omit the unimportant part.
| [WARNING] spurious network error (3 tries remaining): unexpected http status code: 404; class=Http (34) | |
| [WARNING] spurious network error (2 tries remaining): unexpected http status code: 404; class=Http (34) | |
| [WARNING] spurious network error (1 tries remaining): unexpected http status code: 404; class=Http (34) | |
| [ERROR] failed to get `bar` as a dependency of package `foo v0.0.0 ([ROOT]/foo)` | |
| Caused by: | |
| failed to load source for dependency `bar` | |
| Caused by: | |
| Unable to update https://github.com/foo/bar/pull/123 | |
| Caused by: | |
| failed to clone into: [ROOT]/home/.cargo/git/db/123-[HASH] | |
| Caused by: | |
| network failure seems to have happened | |
| if a proxy or similar is necessary `net.git-fetch-with-cli` may help here | |
| https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli | |
| Caused by: | |
| unexpected http status code: 404; class=Http (34) | |
| ... | |
| [ERROR] failed to get `bar` as a dependency of package `foo v0.0.0 ([ROOT]/foo)` | |
| Caused by: | |
| failed to load source for dependency `bar` | |
| Caused by: | |
| Unable to update https://github.com/foo/bar/pull/123 | |
| ... |
There was a problem hiding this comment.
This is the problem with not making this change cause an error. If this is a warning, then after emitting the warning, cargo will attempt to load the github PR url, which is not a git repo, and so that attempt will 404 or some other error (e.g. not a git repo). I think that ... change would make sense though, so committing it as is.
PS. feel free to squash this commit (I know Ed prefers atomic commits in the shape that will end up in the repo, but this is really a single change - not sure how that applies to this project).
There was a problem hiding this comment.
[patch] test also needs the same trick :)
Co-authored-by: Weihang Lo <weihanglo@users.noreply.github.com>
Head branch was pushed to by a user without write access
|
Sorry I've not been able to get back to this and thanks @weihanglo for picking it up. A non-blocking thought (since some improvement is better than no improvement) is to offer something similar for |
|
@rustbot author |
|
@joshka Sorry for heads-up, wondering if you're still working on this? Would you mind if I take over this PR? |
Please do. I've been busy with life and not as available to get things like this over the line. |
|
completed in #16207, closing |
Prior to this, using a github PR URL would cause cargo to attempt to
fetch from an incorrect URL several times before failing.
Providing a github pull request url now fails with an error message
that shows how to fix the problem.
E.g.:
Now gives the following error message:
Fixes: #15001