How to declare different dependencies for multiple binaries

I have one Rust project that compiles to 2 different binary files (one is a CLI and one is a GUI app). The GUI app requires dependencies on tauri but the CLI does not. How should I declare the Cargo.toml to achieve that? Thanks

A part of the Cargo.toml

[[bin]]
name = "app"
path = "src/main.rs"

[[bin]]
name = "cli"
path = "src/cli.rs"

[dependencies]
// The stuff here are shared between both binaries

You would need to use a workspace instead to do that.

1 Like

Hi.

AFAIK, in a workspace cargo will manage both dependencies in a shared Cargo.lock, won't it?

I ask because I have the exact same problem: I have a server that I need to split in two: the Mainstream one, which contains all APIs and is open to cargo update and change, and the Secure one, which I want to deploy new versions with the guarantee that nothing was touched (even dependencies) except things we needed to touch.
What would be the best way to achieve that?

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.