-
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
Support patching one with another package from the same source #9227
Comments
@weihanglo Asked if I could provide some context for why I've needed this as well. At $work, we enforce, among other things, that Rust crates always start with a particular prefix (say,
These are all suboptimal options. Whereas if it were possible to patch in one crate with another, the team could simply add something like [patch.crates-io]
new_foo_instead = { as = "foo", package = "new-foo" } and they'd get the behavior they want. I think there are definitely some open questions here around things like what we do with features, whether there's a potential for resolving require infinite recursion, whether we should instead aim for a more general-purpose dependency graph grafting mechanism, etc., but at least in my mind there's no doubt that this ability is useful. |
AAAAAAAAAAAAAAAAA rust-lang/cargo#9227 AAAAAAAAAAAAAAAAAAAAAAAAAAAA reem/rust-traitobject#7 AAAAAAAAAAAAAAAAAAAAA rwf2/Rocket#1815 and updated libs and fixed deprecation warnings from chrono
We may need this feature as well for using drop-in replacement libraries where the original and the drop-in replacement are both published on crates.io. Edit for context:
|
+1 from me, this would be very useful to us too. |
I just ran into this when I tried to do the following patch
to replace the no longer maintained buf_redux with the recent buffer-redux fork which fixes a future incompatibilities warning. |
We're in a situation where we have many transitive dependencies on I would like to be able to tell cargo that I want all transitive copies of (my current solution to this is doing Crimes™ — i've forked
this is obviously not ideal.) |
When it was noticed that Similarly, |
We talked about this in today's cargo meeting. A potential technical limitation is that patches are on the workspace, the local version of your package will be different than what is published A potential technical impediment is that cargo uses name + (compatible) version for a lot of bookkeeping and this would likely be a big lift to support a different package name or semver incompatible version We suspect an original social reason for the limitation was to discourage long-term patched forks. However, we do feel that there is value in intermediate-term patches that this would help with. Likely the path forward would be for someone to dig in to the how cargo tracks packages and see how feasible it would be to support this before we worry too much about any of the social aspects to this (no point arguing over that if it just can't be done). |
Thank you for the update! |
Any news on this? I came across a situation that really feels like it should be easier: I write an egui application using also egui_struct and catppuccin-egui. Since both additional packages are providing macros to generate egui code, they have egui as part of there public dependency interface. So i have to enforce that the versions are equal between egui, egui_struct.egui and catppuccin-egui.egui. The dependencies seem flexible enough to work properly with just version bumping internally their transitive egui dependency. At the moment i am just able to do this by forking egui_struct and catppuccin-egui, but this is really just too much for just patching one transitive dependency. It seems the patch capabilites of cargo should do exactly that of handling on workspace level the version override even for transitive dependencies, but when i just go for: [patch.crates-io]
egui = "0.26.2" but with this i get: cargo update
Updating crates.io index
error: failed to resolve patches for `https://github.com/rust-lang/crates.io-index`
Caused by:
patch for `egui` in `https://github.com/rust-lang/crates.io-index` points to the same source, but patches must point to different sources I try at the moment also to come around this problem by changing the source to go for egui from git in same version by using:
This leads to not abort anymore on cargo update, but it does not have the desired effect. My cargo.lock file does contain still three different versions of egui and egui_struct and catppuccin-egui do contain outdated egui versions in there dependency list. [[package]]
name = "catppuccin-egui"
version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64bd5a6c2c4bd822735e69d27609fe6fc41e8ec7dd0a7c338dedfdf69fd915b6"
dependencies = [
"egui 0.25.0",
]
[[package]]
name = "egui_struct"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6eca44277ee14d945cd398f91834d696c990c53b7f4ac2796368ce2b09b5c6c"
dependencies = [
"egui 0.23.0",
"egui_struct_macros",
]
[[package]]
name = "egui"
version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bd69fed5fcf4fbb8225b24e80ea6193b61e17a625db105ef0c4d71dde6eb8b7"
dependencies = [
"ahash",
"epaint 0.23.0",
"nohash-hasher",
]
[[package]]
name = "egui"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0bf640ed7f3bf3d14ebf00d73bacc09c886443ee84ca6494bde37953012c9e3"
dependencies = [
"ahash",
"epaint 0.25.0",
"nohash-hasher",
]
[[package]]
name = "egui"
version = "0.26.2""git+https://github.com/emilk/egui?tag=0.26.2#309586b42cc809af7e262a194eef5c35013d1bf1"
dependencies = [
source =
"accesskit",
"ahash",
"epaint 0.26.2 (git+https://github.com/emilk/egui?tag=0.26.2)",
"log",
"nohash-hasher",
"puffin",
"ron",
"serde",
]
What is the desired way to just enforce some transitive dependencies to run the same version without the need of forking the dependencies? |
Describe the problem you are trying to solve
I want to patch an indirect dependency. And cloning the dependency can take a lot of time due to huge history, so I publish the patched version to crates.io with a different name and suppose to patch the dependency with the new name. I tried
But it will report
Seems only
git
andpath
are supported.Describe the solution you'd like
Supporting patch one dependency with another dependency from registry.
Notes
The text was updated successfully, but these errors were encountered: