Skip to content

cargo fails when patch overrides only a git branchΒ #5615

Closed
@olix0r

Description

@olix0r

I have two crates: conduit-proxy and tower-h2. conduit-proxy depends on tower-h2 via a git dependency:

tower-h2              = { git = "https://github.com/tower-rs/tower-h2" }

I add another crate into the tower-h2 repo, tower-h2-balance. Before I merge tower-h2-balance to master, I want to test it in conduit-proxy, so I add a dependency:

tower-h2-balance      = { git = "https://github.com/tower-rs/tower-h2" }

Then, I'd like to patch these dependencies to use my working branch in the tower-h2 repo:

[patch."https://github.com/tower-rs/tower-h2"]
tower-h2         = { git = "https://github.com/tower-rs/tower-h2", branch = "ver/tower-h2-balance" }
tower-h2-balance = { git = "https://github.com/tower-rs/tower-h2", branch = "ver/tower-h2-balance" }

This is especially necessary because tower-h2 is a diamond dependency (i.e. it is also depended on by another dependency of conduit-proxy), and so it's important that these middle dependencies are patched to use the proper version of tower-h2.

After making this change, cargo check emits the following error:

error: failed to resolve patches for `https://github.com/tower-rs/tower-h2`

Caused by:
  patch for `tower-h2` in `https://github.com/tower-rs/tower-h2` points to the same source, but patches must point to different sources

Is this expected to work? If not, is there a suggested workaround?

For now, I've used .cargo/config to override the dependency, but this is brittle (and I get a big ugly warning about it).


active toolchain
----------------

stable-x86_64-apple-darwin (default)
rustc 1.26.2 (594fb253c 2018-06-01)
:; cargo version
cargo 1.26.0 (0e7c5a931 2018-04-06)

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