1

I have a workspace with two projects as below

workspace/
├─ project-a/
│  ├─ src/
│  ├─ Cargo.toml
├─ project-b/
│  ├─ src/
│  ├─ Cargo.toml
├─ Cargo.toml

Project b depends on project a, it launches the binary file generated by project a with std::process::Command.

In /workspace/project-b/Cargo.toml, I set the dependencies as below.

[dependencies]
project-a = { path = "../project-a" }


[dev-dependencies]
project-a = { path = "../project-a" } 

And in /workspace/Cargo.toml, I set default entry to be project b.

[workspace]
members = [
    "project-a",
    "project-b",
]
default-members=["project-b"]

It works well if I run cargo run in `/workspace`` directory, project-b can successfully launches project-a as a child process.

But when I modify the code in /workspace/project-a``, cargo run in /workspace directory will not compile the updated code. Still I need enter /workspace/project-a/ directory and execute cargo run once more.

How can I make cargo run in `/workspace`` directory automatically compiles its dependencies?

Mr.Wang from Next Door
  • 13,670
  • 12
  • 64
  • 97
  • Based on these issues: https://github.com/rust-lang/cargo/issues/7971, https://github.com/rust-lang/cargo/issues/872, it looks like cargo does not support this at this time. However, if it is not essential for `project-a` and `project-b` to be separate crates, you may be able to use this solution instead: https://stackoverflow.com/questions/36604010/how-can-i-build-multiple-binaries-with-cargo – AlphaModder Mar 25 '21 at 05:29

0 Answers0