Cargo.toml dependencies and git branches

The Real Problem (in case this is an XY problem):

I have a Rust application that uses two libraries each in a separate git repository on our corporate server.

I'm working on branches, making changes that require bumping the versions of the libraries that the main project uses. I want to be able to do a test build from branches using the final versions of the Cargo.toml files.

What I want:

The behavior that I want is something along the lines of "look on any git branch for a version number, but only if I tell you from the command line" That way I can test this code with the "real" Cargo.toml files. Otherwise we're either going to have to check the "lower down" libraries into git in their final versions, then edit the .toml files in the next layer up, etc., until we're done.

You could build the crates within a workspace, and create a [patch] section in the workspace's top-level Cargo.toml file as described in Overriding Dependencies.

This is not quite as convenient as a command-line switch, since you'll still need to modify the workspace Cargo.toml in order to enable/disable the overrides, but it will let you test the code without modifying the individual packages' Cargo.toml files.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.