-
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
No way to [patch] out multiple versions of a crate #6169
Comments
I've pointed this out back in the RFC's thread and it got a positive response by @alexcrichton but I can't recall it being picked up in the RFC's text afterwards. It seems to have gotten lost somewhere in the process :). Partly my fault for not pointing it out when I read the RFC's text. |
@erickt generally patching dependencies for portability is pretty difficult with cargo right now (i mostly port stuff to embedded targets, which means can easily span half the dependency graph). Is that something you'd be interested in fixing? possibly outside of cargo, since that seems a little burdened with feature requests already. i'm thinking of a thing that does a generell "replace crate a with crate b" unchecked |
A strawman of supporting this would possibly look like: [patch.crates-io]
my-crate = { git = 'https://github.com/myuser/my-crate', branch = 'v1' }
my-crate2 = { git = 'https://github.com/myuser/my-crate', branch = 'v2', package = 'my-crate' } ... or ... [patch.crates-io]
my-crate = [
{ git = 'https://github.com/myuser/my-crate', branch = 'v1' },
{ git = 'https://github.com/myuser/my-crate', branch = 'v2' },
] |
At the moment this is blocking TiKV from adopting |
Sat down to write a patch and turns out this already works! #[cargo_test]
fn multipatch() {
Package::new("a", "1.0.0").publish();
Package::new("a", "2.0.0").publish();
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
[dependencies]
a1 = { version = "1", package = "a" }
a2 = { version = "2", package = "a" }
[patch.crates-io]
b1 = { path = "a1", package = "a" }
b2 = { path = "a2", package = "a" }
"#,
)
.file("src/lib.rs", "pub fn foo() { a1::f1(); a2::f2(); }")
.file(
"a1/Cargo.toml",
r#"
[package]
name = "a"
version = "1.0.0"
"#,
)
.file("a1/src/lib.rs", "pub fn f1() {}")
.file(
"a2/Cargo.toml",
r#"
[package]
name = "a"
version = "2.0.0"
"#,
)
.file("a2/src/lib.rs", "pub fn f2() {}")
.build();
p.cargo("build").run();
} |
Document that `package` can be used in `[patch]` This works to `[patch]` multiple versions of a crate, and turns out this has worked since the inception of `package`! Closes #6169
I know there is now a well-defined workaround, but is there merit to the idea of [patch.crates-io]
'my-crate:1' = { git = 'https://github.com/myuser/my-crate', branch = 'v1' }
'my-crate:2' = { git = 'https://github.com/myuser/my-crate', branch = 'v2' } |
Fuchsia is using cargo-vendor to collect our dependencies, and we're using
[patch]
to remove a few indirect dependencies that we know we don't need, like winapi (see here). Unfortunately, because our dependency graph is a little large, it turns out our graph depends on both winapi 0.2.8 and 0.3.6, but[patch]
only allows us to only patch out one version. It would be great if we could do this for all versions.The text was updated successfully, but these errors were encountered: