-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Specify "default-run" binary in a workspace project #7290
Comments
If you set |
That looks good @ehuss !! Thanks! I've wondered in the past what was the purpose of "members" and "default-members". |
|
Thanks. That helps. Should have spotted it before. |
OK, so now I just did find a downside to that approach. Before, I could execute the binary in any of the sub-projects by using Here's a simplified version before[workspace] I could execute flowc or flowr using the --bin option, but it is always needed after[workspace] "cargo run" runs "flowc" as discussed - great.
` |
Can you try out the latest nightly version? Just a few days ago, we changed this behavior (#7270), which I think should match your expectations. |
I tried with nightly and seems to be the same behaviour to me:
|
Oh, I may have misread what you were doing. You should be able to run You can also set up an alias to do whatever you want it to do. |
aha! |
Also it would be helpful to improve the error message:
when
|
Hmm, this works, but it also affects all other commands (e.g. |
…lacrum Move some more bootstrap logic from python to rust Same rationale as rust-lang#76544; it would be nice to make python entirely optional at some point. This also removes $ROOT as an option for the build directory; I haven't been using it, and like Alex said in rust-lang#76544 (comment) it seems like a misfeature. This allows running `cargo run` from src/bootstrap, although that still gives lots of compile errors if you don't use the beta toolchain. It's not exactly the same as using `x.py`, since it won't have `BOOTSTRAP_DOWNLOAD_RUSTC` set, but it's pretty close. Doing this from the top-level directory requires rust-lang/cargo#7290 to be fixed, or using `cargo run -p bootstrap`. The next steps for making python optional are to move download-ci-llvm and download-rustc support into rustbuild, likely be shelling out as the python scripts do today. It would also be nice (although not required) to move submodule support there, but that would require taking bootstrap out of the workspace to avoid errors from crates that haven't been cloned yet. r? `@Mark-Simulacrum`
This creates a new binary package to use and adds it to the workspace. Unfortunately there doesn't seem like a good way to make it the default run command for the entire workspace. See this issue for more details: rust-lang/cargo#7290
This is done by specifing a single default package in the top-level `Cargo.toml`: rust-lang/cargo#7290
I know it has been a couple years, but I think this ticket should be re-opened on these grounds. To add a real world example: We have a cargo workspace for one of our backend services. We have a "primary" binary inside a crate (call it We also have other supporting crates, one of which is a custom testing framework (call it We want to, but are unable to configure the following behavior:
|
Funny, I just hit this today and found @mathew-horner commented on the same day. As I understand it, the current recommendation is to use some combination of On the one hand, I acknowledge that workspaces, packages, and crates are different things, and I could see wanting to avoid an explosion of duplicate, potentially-confusing set options across all of them. On the other hand, I would argue that this is a usability issue, and if the official stance was not to introduce unnecessary options, I'm not sure It just seems like a completely natural thing to have a |
Describe the problem you are trying to solve
I have a workspace project with a Cargo.toml in the root, then various sub-projects in sub-folders, each with their own Cargo.toml files that specify specific packages (libs or binaries).
I often have to execute one of the resulting binaries on test apps during development.
I am pleased to see the addition of the "default-run" key to Cargo.toml in packages section.
In general this will help.
In this project I don't have any sub-project that has multiple binaries built.
I do have multiple binaries built in the overall workspace, one in each of a number of sub-projects.
Describe the solution you'd like
I would like to be able to specify "default-run" in the root workspace Cargo.toml file, so from the project root I can run "cargo run -- " on some test files, without having to specify the binary with
--bin <binary_name>
each time.Notes
Not sure under which key would make sense in the workspace toml.
Format something like:
default-run = "sub-folder/binary_name"
?The text was updated successfully, but these errors were encountered: