-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Allow same source git patches with different rev / branch, etc. #10756
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
Comments
Semi-related: #10667 Source replacement for git URL doesn't support rev and branch. |
Bumping this up, this is a blocker for private project development where forks are not an option. Patching a project to override a crate dependency with a different branch of the same repo would be the way to go but is impossible right now because of this URL check. A solution would be to compare the whole package specification (including any tag, branch, commit clause) and block only if every field is the same. I could start work on a PR for it if this solution makes sense and the interest is there. |
I definitely agree that it should be supported in cargo properly, but just to mention a workaround in case it's useful to anyone: it's possible to trick cargo into thinking that it's a different repo by using a double slash in the URL, like this: [patch.'https://github.com/owner/repo']
baz = { git = 'https://github.com/owner//repo', branch = 'my-branch' } Cloning |
@dimonomid I have tried this on Windows and I would like to report that it did not work. Maybe this is a linux-only workaround? |
I'm not a Windows expert and don't have it around to try it right now, but I didn't expect that it wouldn't work. Could you share what is the error message? |
### What ndc-spec v0.1.0-rc.8 uses workspace inheritance to set the version and edition, which unfortunately does not work with Crane for Nix (when using Git targets). I have inlined the version and edition to solve this, but we also need to release a new version of ndc-spec and update ndc-sdk. Until that happens, let's just override it (transitively) using `patch` in _Cargo.toml_. ### How [`[patch."..."]`, in _Cargo.toml_](https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section), allows us to hijack a dependency and point it somewhere else. Unlike just setting the version, this works transitively, so it will also update ndc-sdk. This is important because it's the dependency build step which fails in Crane, so we need to ensure we have no reference to the previous version. Unfortunately, there's an open bug in Cargo which means that [patch overrides can't use the same Git repository](rust-lang/cargo#10756), even if the commit reference is different. We work around this by adding an extra "/" to trick Cargo into thinking it's a different repository.
This uses a URL that still follows the Cargo.toml specification, but still works around <rust-lang/cargo#10756>. This fixes Cargo recording valid URLs in the lockfile and correctly finding the dependency when using `cargo vendor` (otherwise `cargo --offline` will not work with vendored sources).
This fixes Cargo recording valid URLs in the lockfile and correctly finding the dependency when using `cargo vendor` (otherwise `cargo build --offline` will not work with vendored sources). It uses a URL that follows the Cargo.toml specification, but still works around <rust-lang/cargo#10756>.
This fixes Cargo recording valid URLs in the lockfile and correctly finding the dependency when using `cargo vendor` (otherwise `cargo build --offline` will not work with vendored sources). It uses a URL that follows the Cargo.toml specification, but still works around <rust-lang/cargo#10756>.
This fixes Cargo recording valid URLs in the lockfile and correctly finding the dependency when using `cargo vendor` (otherwise `cargo build --offline` will not work with vendored sources). It uses a URL that follows the Cargo.toml specification, but still works around <rust-lang/cargo#10756>.
That's worked for me on windows, also with ssh paths.
|
Just found this is exactly the same issue as #5478. Close in favor of that. |
Problem
Currently if I wanted to override and patch dependency across workspace of a dependency
https://github.com/owner/repo
to branchb
this does not workbecause of the input validation here
cargo/src/cargo/core/registry.rs
Lines 363 to 371 in 1366225
Proposed Solution
Remove the validation or make an exception when the source is a git url?
Notes
No response
The text was updated successfully, but these errors were encountered: