Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cargo run should discover executables in workspace packages #3713

Closed
sunjay opened this issue Feb 15, 2017 · 1 comment · Fixed by #5877
Closed

cargo run should discover executables in workspace packages #3713

sunjay opened this issue Feb 15, 2017 · 1 comment · Fixed by #5877
Labels
A-workspaces Area: workspaces C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-run

Comments

@sunjay
Copy link
Member

sunjay commented Feb 15, 2017

I recently left this comment on #3529 but unfortunately that issue was fixed and closed before my suggestion could be taken into account. I asked @alexcrichton and he said it would work for me to just create a new issue here.

Here's my original suggestion from that issue:

Would love to see this! Even better would be if I could use the same run syntax as before but cargo would build and run the appropriate executable in my packages.

To explain further, let's say I had this structure:

src/
  bin/
    a.rs
    b.rs
    bb.rs

I used to be able to run:

cargo run --bin a
cargo run --bin b
cargo run --bin bb

With workspaces, I split that into two crates like this:

a/
  src/
    bin/
      a.rs
b/
  src/
    bin/
      b.rs
      bb.rs

It would be really nice if I could still run the same commands as above. The executable names are still the same and unique. They just belong to different crates in the same workspace now.

If the executables across crates aren't unique, then you should definitely make -p required, but otherwise it's way more ergonomic (and easier to remember) to just use the old commands.

It's the difference between cargo run -p b --bin b and cargo run --bin b.

Basically, it would be great if cargo run could run binaries from any package within a workspace. That way you could be sitting at the workspace root and run executables that you would normally have to change directories to run.

@alexcrichton also mentioned that this might be neat for tests as well.

@nixpulvis
Copy link

I'd even be ok with cargo run --bin foo/bar for deeper nesting of projects.

@carols10cents carols10cents added A-workspaces Area: workspaces C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-run labels Sep 29, 2017
bors added a commit that referenced this issue Aug 9, 2018
Allow `cargo run` in workspaces.

Closes #3713
@bors bors closed this as completed in #5877 Aug 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-workspaces Area: workspaces C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-run
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants