Skip to content

Commit 6e88e37

Browse files
authored
workspace: avoid duplicates when pulling dependency from git (#696)
When pulling dependencies using a `patch.crates-io` to a git dependency like: ``` [dependencies] sha1 = "0.11.0-rc.0" [patch.crates-io] sha1-checked = { git = "https://github.com/RustCrypto/hashes.git" } ``` Cargo will duplicate sha1 dependency: ``` [[package]] name = "sha1" version = "0.11.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f9318facddf9ac32a33527066936837e189b3f23ced6edc1603720ead5e2b3d" dependencies = [ "cfg-if", "cpufeatures", "digest 0.11.0-rc.0", ] [[package]] name = "sha1" version = "0.11.0-rc.0" source = "git+https://github.com/RustCrypto/hashes.git#2bcfb5a0a849503ed73b190538787a00c58baada" dependencies = [ "cfg-if", "cpufeatures", "digest 0.11.0-rc.0", ] [[package]] name = "sha1-checked" version = "0.11.0-pre" source = "git+https://github.com/RustCrypto/hashes.git#2bcfb5a0a849503ed73b190538787a00c58baada" dependencies = [ "digest 0.11.0-rc.0", "sha1 0.11.0-rc.0 (git+https://github.com/RustCrypto/hashes.git)", "zeroize", ] ``` This causes issues further down the line, for example when the downstream client is built with nix which does not support two copies of the same crate/version tuple. This switches the local overrides using a workspace patch instead which are not used when the crate is consumed via git.
1 parent 2bcfb5a commit 6e88e37

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,8 @@ members = [
2828

2929
[profile.dev]
3030
opt-level = 2
31+
32+
[patch.crates-io]
33+
sha1 = { path = "sha1" }
34+
sha3 = { path = "sha3" }
35+
whirlpool = { path = "whirlpool" }

fsb/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ categories = ["cryptography", "no-std"]
1414

1515
[dependencies]
1616
digest = "0.11.0-rc.0"
17-
whirlpool = { version = "0.11.0-rc.0", path = "../whirlpool", default-features = false }
17+
whirlpool = { version = "0.11.0-rc.0", default-features = false }
1818

1919
[dev-dependencies]
2020
digest = { version = "0.11.0-rc.0", features = ["dev"] }

k12/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ categories = ["cryptography", "no-std"]
1414

1515
[dependencies]
1616
digest = "0.11.0-rc.0"
17-
sha3 = { version = "0.11.0-rc.0", default-features = false, path = "../sha3" }
17+
sha3 = { version = "0.11.0-rc.0", default-features = false }
1818

1919
[dev-dependencies]
2020
digest = { version = "0.11.0-rc.0", features = ["alloc", "dev"] }

sha1-checked/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ exclude = [
1919

2020
[dependencies]
2121
digest = "0.11.0-rc.0"
22-
sha1 = { version = "0.11.0-rc.0", path = "../sha1", default-features = false }
22+
sha1 = { version = "0.11.0-rc.0", default-features = false }
2323
zeroize = { version = "1.8", default-features = false, optional = true }
2424

2525
[dev-dependencies]

0 commit comments

Comments
 (0)