Cargo patch sections doesn't work?

I have been following the material in https://doc.rust-lang.org/cargo/reference/manifest.html and https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html but cannot get a patch section to do what it should. I also tried replace and it also didn’t seem to work.

[dependencies]
…
gstreamer-sys = { git = "https://github.com/sdroege/gstreamer-sys", features = ["v1_12"] }
gstreamer-mpegts-sys = { git = "https://github.com/sdroege/gstreamer-sys" }

[patch."https://github.com/sdroege/gstreamer-sys"]
gstreamer-sys = { git = "file:///home/users/russel/Repositories/Git/Forks/GStreamer_Sys", branch="rw_mpegts", features = ["v1_12"] }
gstreamer-mpegts-sys = { git = "file:///home/users/russel/Repositories/Git/Forks/GStreamer_Sys", branch="rw_mpegts" }

doesn’t lead to my local Git repository being used. Am I just doing something trivially wrong? I hope so.

Could you try removing and recreating the lock file?

If there’s gstreamer version u in the lock, and the pathc contains gstreamer version v, where u != v (even if it’s semver-compatible), the patch won’t be used.

Patch works as if you publish it to crates IO. Publishing new minor version does not affect you, if you already have a lockfile.

I always do “cargo clean; cargo update; cargo build” to try and ensure no hysteresis in the lock file, but I will have to admit I have tried deleting the lock file. I shall try that now.

Could it be that the fact that there are many subprojects in a superproject be a factor here?

I think patch works only in the root of workspace, though I am not sure. I don’t seem to have any additional advice, without looking at the project’s code.

The two repositories are https://github.com/sdroege/gstreamer-sys and https://github.com/sdroege/gstreamer-rs/ I am working on the gstreamer-mpegts subproject. The idea is to have changes in my local clones in the rw_mpegts branch of both and be able to compile and test changes in my clone of GStreamer_Rs using the local clone changes to GStreamer_Sys so as to test both prior to making pull requests for either.

Currently I am having to put untested changes into the mainline repository of GStreamer_Sys before being able to do any tests in my clone of the GStreamer_Rs repository.

It turns out that putting the patch section in the top-level project/workspace Cargo.toml instead of the subproject Cargo.toml does the needful. Thanks to Arvid E. Picciani and David Hewson on Twitter for pushing me in the right direction. Everything now seems to work and much progress can be made. :slight_smile: