Best practice to dev with local dependencies

It is a common situation where there is a common Rust workspace containing infrastructure crates, and we further develop separate high-level crates with those basic libraries. However, those high-level crates are not logically closely related to the basic libraries, so it is better not to organize them into one single workspace.

In this situation, what is the best practice to write those local dependencies? As the code will be uploaded to git, it is not wise to use local path as dependencies. But when we dev high-level codes, it is common that we also need to adjust the low-level basic libraries with added functionalities. In that case, committing the low-level libraries, cargo update the high-level codes, will be too inefficient and may lead to mess commit history especially when we are adjusting and debugging.

So currently, I use local path as dependencies when developing, and before committing, I modify the dependency to be git url. I don't know if this is the best practice, and to be honest, I often forget the last step :frowning:

https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#overriding-repository-url

Thank you for this link. However, this configuration is used in Cargo.toml, which means we may upload the local path to Git, which may not be a good practice?

It's an append only way to patch the dependency. You can add a CI check of [patch] section to prevent accidental push.

2 Likes