-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Patch git dependency in a workspace or sub-directory #9624
Comments
Because of this lack of functionality, I am currently forced to download the whole repo, store it somewhere, and override each dependency of a workspace in a patch section like this: [patch.crates-io]
cpp = { path = "../../rust-cpp/cpp" }
cpp_common = { path = "../../rust-cpp/cpp_common" }
cpp_macros = { path = "../../rust-cpp/cpp_macros" }
cpp_build = { path = "../../rust-cpp/cpp_build" } Instead, I'd like to be able to write something like this: [patch.crates-io]
cpp = { git = "https://github.com/mystor/rust-cpp", member = "cpp" }
cpp_common = { git = "https://github.com/mystor/rust-cpp", member = "cpp_common" }
cpp_macros = { git = "https://github.com/mystor/rust-cpp", member = "cpp_macros" }
cpp_build = { git = "https://github.com/mystor/rust-cpp", member = "cpp_build" } |
Cargo should automatically find the package based on the name. That is, you should be able to write: [patch.crates-io]
cpp = { git = "https://github.com/mystor/rust-cpp" }
cpp_common = { git = "https://github.com/mystor/rust-cpp" }
cpp_macros = { git = "https://github.com/mystor/rust-cpp" }
cpp_build = { git = "https://github.com/mystor/rust-cpp" } Does that work for you? |
Works on Linux now. How strange. I'm almost sure I tried exactly that, and it didn't work yesterday on Windows. I'll check Windows again soon. |
Nevermind my stupidity. git patches work with workspaces on Windows too. Anyway, it probably worth mentioning in the documentation that workspaces are explicitly supported. |
However, No good: qttypes = { path = "../../qmetaobject-rs" }
qmetaobject = { path = "../../qmetaobject-rs" }
qmetaobject_impl = { path = "../../qmetaobject-rs" } Good: qttypes = { path = "../../qmetaobject-rs/qttypes" }
qmetaobject = { path = "../../qmetaobject-rs/qmetaobject" }
qmetaobject_impl = { path = "../../qmetaobject-rs/qmetaobject_impl" } |
I think it is unlikely that we will change the |
Is being inconvenient and inconsistent with `git = ` counts as a problem?Besides, the whole thing is poorly documented (no examples for workspaces, no mentions of differences between git and path), and that definitely should be improved.
|
If anyone wants to give a hand with this, here are some pointers for the possible enhancements:
I am not good at writing so feel free to sumbit a PR with better wordings than this! |
If no one else is working on this, I'd be happy to make this change! |
@weihanglo I've noticed that when duplicate crates are discovered in a git repository, Cargo actually selects one of them, and a "Skipping duplicate package ..." warning is issued for each skipped crate. It seems that the eventually selected crate is the one that was discovered first, but I'm not certain what determines the discovery order: cargo/src/cargo/ops/cargo_read_manifest.rs Lines 181 to 197 in c9d8c28
Would you have any guidance on whether/how this behaviour should be documented? |
Hi, @wabisabia. Sorry for the late response. I don't know why it is off my radar. We can skip the skipping behavior for now. It's not reliable and is considered as a bug, see #10752 (comment). If you come up with any better idea or question, please share with us! |
If this is still relevant I'd like to submit a PR. Pages in question: |
* minor rephrasing for readability * added more examples * added sub-headings * rearranged a few paragraphs for readability
* rephrasing for readability * added more examples * added sub-headings * rearranged paragraphs for readability
* rephrasing for readability * added more examples * added sub-headings * rearranged paragraphs for readability
Describe the problem you are trying to solve
Patch syntax allows replacing a dependency's git URL, but it doesn't seem allow to specify a directory in that repository. At least, it is not documented at https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html. Essentially, it is useless when patched crate is a part of a cargo workspace.
Describe the solution you'd like
Two solutions:
More integrated with cargo/rust: specify workspace member's package name, so that cargo will parse manifest and resolve to the required directory automatically.
More general: manually specify sub-directory of a git repository, so that cargo would look for a crate's
Cargo.toml
manifest in that dir.Notes
I think, both proposed solutions are fine and can be implemented concurrently and without interfering each other.
Related: #6126
The text was updated successfully, but these errors were encountered: