-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Allow specifying pull request deps using the github PR link #15001
Comments
For Option 1, we'd be pulling github into our compatibility story which is not great. Option 2 is more viable. One question would be what hosting services (and enterprise deployments) should we support. As patches are likely what should be encouraged in these scenarios, we should make sure we support those as well with whatever we do. Speaking of patches, another option is to have support added in https://crates.io/crates/cargo-override in some form. I don't remember if the author would like to eventually have it merged into cargo. As its likely not there yet, experimenting with this now is a lot more feasible. Even when its merged, it might be possible to "just work". This would likely be a UX command like |
This really comes down to how much to apply Postel's law.
The reason why I don't think this is a big problem is that we're talking about a string. It's not like this would impose any requirement on any consumer to load a library to interpret this / be compatible. The fact that we're discussing this issue on GitHub is proof enough suggests that avoiding being compatible with GitHub shouldn't be a high priority. The one thing where I'm likely downplaying in that is that once you support a specific value like this, then you support it forever (or at least until you bump a version field). This seems intuitively not to be a huge problem, but I'd seek your opinion there as I may be missing some context.
Not quite sure I'm grokking this. Are you talking about also supporting direct links to diff patch urls on github, or are you talking about future updates to the code which would be written for this? If it's the former, then this is just another branch of the logic, so fairly simple. If it's the latter then the answer is that any naive implementation of either option is not a one-way door to implementing further support.
I think that a lot of people see the Cargo.toml file as the primary user interface that drives dependency resolution. Pick any random crate README and you'll see "add this to your Cargo.toml" more often than "cargo add foo". To me this says that cargo should handle errors nicely. |
Thanks for the feedback! Here are problems of option one I am aware of
Sorry I was just dumping my thoughts here. Not meant to devalue the discussion. |
If GitHub changes that, then any manifests which use refs already will fail. (That said, there's surprisingly few places that take advantage of this. I would have thought it would be much more. https://github.com/search?q=path%3ACargo.toml+%22rev+%3D+%5C%22refs%22&type=code)
I think this is a sufficient argument to not do Option 1.
Also a good argument for not doing Option 1
No need to apologize. You convinced me (easily) that my assumptions were wrong by giving me the missing info I needed to adjust them. Thanks! I have a PR incoming for Option 2. See #15003 |
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
If you are temporarily overriding a dependency to use the result of a PR, then the expected workflow for that is to patch the dependency, rather than edit the dependency specification. The command This means any fix for this workflow should apply to patches as equally or more than dependency specifications. |
Got it. Of the 3 interpretations of patches I saw the other 2 and missed the obvious one. I mentally mapped what you're referring to as a (patch) override, rather than a patch. |
Problem
From time to time I need to submit a PR to a lib and then want to rely on that PR in my local code.
Every time I do this I have to search the docs to work out the specific syntax that I need.
It would be nice if I could just use GitHub's PR syntax for this (or at the very least the error message should point me in the right direction)
Proposed Solution
Option 1. Support this as-is:
I understand why this might not be ideal even if it's the most developer friendly fix for this. So alternatively:
Option 2. Provide a better error message for this scenario that provides the right syntax:
Current error message:
Expected error message (something like):
Notes
I understand that there's other code forges than GitHub, but it's reasonable to fix the 99% case even when other cases are not fixed.
The text was updated successfully, but these errors were encountered: