Patch section doesn't get applied for a dependency from workspace

I'm trying to write a package which depends on Holochain. The repository is a workspace, with the crate I need (holochain) being under crates/holochain. So I have this in my Cargo.toml:

[dependencies.holochain]
git = "https://github.com/holochain/holochain"
branch = "develop"
package = "holochain"

holochain has the following patch section in workspace Cargo.toml:

My package fails to compile, unless I duplicate this patch section in my Cargo.toml, which seemed unexpected to me. Is that expected behaviour, and I should just ask them to depend on patched packages directly?

Yes, this is expected: [patch] sections are only used if they are in the Cargo.toml of the top level package/workspace that you are building.

If these are temporary patches only for the development version, then it might be reasonable to expect other people building against this version to copy the patch section into their own Cargo.toml. If they are more permanent, then depending directly on the forked versions might be better.

1 Like