Skip to content

Conversation

baloo
Copy link
Member

@baloo baloo commented Jun 4, 2025

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.

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.
@tarcieri tarcieri merged commit 6e88e37 into RustCrypto:master Jun 4, 2025
239 checks passed
@baloo baloo deleted the baloo/workspace/patch-crates-io branch June 4, 2025 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants