Skip to content

Add [patch.crates-io] to unify duplicate registry/git crate sources #6234

@aldoborrero

Description

@aldoborrero

The workspace Cargo.lock contains three crates that appear from both crates.io and git forks with the same name-version:

  • bls12_381 v0.8.0 — registry + https://github.com/lambdaclass/bls12_381 (branch expose-fp-struct)
  • halo2curves-axiom v0.7.2 — registry + https://github.com/axiom-crypto/halo2curves.git (tag v0.7.2)
  • zkhash v0.2.0 — registry + https://github.com/HorizenLabs/poseidon2.git (rev bb476b9)

This works fine with cargo build (which resolves from the lockfile), but breaks vendoring tools like cargo vendor and Nix's importCargoLock/fetchCargoVendor, which cannot handle two sources for the same package name-version:

error: found duplicate version of package `bls12_381 v0.8.0` vendored from two sources

Adding these lines to the workspace Cargo.toml would unify the sources and fix vendoring:

[patch.crates-io]
bls12_381 = { git = "https://github.com/lambdaclass/bls12_381", branch = "expose-fp-struct" }
halo2curves-axiom = { git = "https://github.com/axiom-crypto/halo2curves.git", tag = "v0.7.2" }
zkhash = { git = "https://github.com/HorizenLabs/poseidon2.git", rev = "bb476b9" }

This tells Cargo to always use the git fork instead of the registry version, eliminating the duplicate. The existing Cargo.lock resolution stays the same — it just makes vendoring work.

Found while packaging ethrex for nix-community/ethereum.nix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions