Override dependency only locally

Imagine I have a main project with a dependency. I'm also an author of that dependency. Now I would like to use my locally checked out version of that dependency in the main project.

Is there a configuration file where I can put [patch] sections, like in Cargo.toml but only for my local use? Cargo.toml is under version control and thus shared with other developers.

Cargo.toml is the canonical place for dependency declaration, so no there's no other place.

What I do is simply make the changes and not commit them.

You can use a .cargo/config file for local-only configuration. The syntax for overriding dependencies in the config file is a bit different; instead of patch you can use the paths key:

https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#paths-overrides

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.