-
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
Is --out-dir
justified or can we find another way of accomplishing it?
#6100
Comments
I do think it makes sense to keep these separate. I like the idea of having |
I think it is important that we have both of these features:
UI-wise, using flags for these seems better: the "build system" code, like ci-scripts, tends to be poked by many people, so it's important to keep it easy to understand without prior knowledge, and flags are better than env vars in this respect. I do agree that for most of the users, interacting with Cargo's CLI, these flags are irrelevant. However, this could be said about some other flags as well, like |
I am unhappy with the UX of having all of these flags also. For a long time we've been creeping in the direction of having flags to customize every user visible aspect of the behavior, because this has been how CLI tools traditionally handle users wanting to customize their behavior. However, I think this has a bad UX overall, because it makes the tool overwhelming and ultimately makes all of the flags undiscoverable. I think hiding these tools from I think a preferable approach to what we've done would be to provide some lower level command which takes as many flags as you want and can be used to build up the user-oriented commands like So I noticed a few days ago that when I ran It was in the process of investigating how the flags to cargo build had proliferated that I noticed these two flags. I think there's a larger problem here, but these two flags in particular have such similar behavior that keeping them both has unique negative UX consequences aside from the general concern. From the An obvious way to help resolve their close similarity is to clarify the differences in the |
I'm personally fine adding these flags basically wherever makes sense, but to echo @matklad I don't think we'll want to remove the functionality. In that sense I would want to make sure that these sorts of configurations (which you're 100% right @withoutboats, will continue to get added to seemingly no end) have some home somewhere. They're definitely not important to surface in high-profile locations, just need to be located somewhere! |
We discussed this & also the overarching issue a bit in the cargo meeting yesterday. The sort of overarching viewpoint was that it would be ideal to expose these kinds of knobs through a set of lower level primitive commands on top of which sit the more user oriented commands (git has this distinction for example, calling them "porcelain" and "plumbing"). However, the problem with doing that is that it requires major refactors which seem difficult or infeasible. On the other hand, by adding all of these knobs incrementally we end up with the same functionality, but with worse UX (from having the functionality exposed through a bunch of flags on the main commands), and worse maintainability (because those flags are being threaded through the entire codebase). But back to the problem of pulling off a refactor, and so we ended at a standstill. |
Was there a good idea of what the porcelain/plumbing mode would actually look like in Cargo? In abstract it makes sense but if there's a concrete idea where to go it may not be so bad to draw up an issue and start soliciting help for making progress |
Is there any chance of |
It seems to be related, but a bit backwards, to temp vs non-temp separation of directories proposed in #6227 |
I would also like to see |
I found the |
I recently had a couple of people express an interest in |
|
Oh wow, I think there's a very confusing point here, which we somehow didn't noticed before.
|
Coming back to this after a couple of years, I feel that maybe adding Of the top of my head:
|
Can I configure |
Unfortunately changing the layout of the Instead, if we could have an output directory that is guaranteed to only contain the final artifacts, that would enable us to declare the layout of the An alternative is to move towards deprecating the |
@dpaoliello I've imagined this done in reverse: keep the final build artifacts that people care about in the target dir where they are, but start moving everything else (temp files, compiler-private junk) to some other directory (such as platform's preferred cache and temp dirs). |
Is it possible to make |
+1 for @stevenhansel suggestion. I have different environments for building tests and running them. It's quote cumbersome to find test in
|
Another reason for providing this is that you can't know where the target folder is without not just reading the So if you want to write e.g. a vscode task that compiles the code and moves the binary somewhere, you can either
both of which aren't good options. |
Just leave it here: https://github.com/bazhenov/cargo-export |
Adding a vote for making --out-dir a safe operation. It is nice to be able to specify where the final artifact will be placed. Currently opting for a subsequent |
I don't think the use case was explicitly mentioned (although related CI use cases were): I use a global |
Access to artifacts is also coming up in rust-lang/rfcs#3371 |
--out-dir
justified or can we find another way of accomplishing it?
Rename --out-dir to --artifact-dir Progress towards unblocking #6790. Renames the experimental `--out-dir` argument to `--artifact-dir`, both to reflect that it's where the final build *artifacts* will be copied to, and to avoid confusion with the `OUT_DIR` environment variable which serves an entirely different purpose. For transition purposes, `--out-dir` argument and `out-dir` config key will still work with a deprecation message encouraging the use of the new arg and config key. ### Rationale A lot of people seem to be confused by the naming of the `--out-dir` argument, and are misled into thinking it serves the same purpose as the `OUT_DIR` environment variable: > [However, it doesn't seem that OUT_DIR environment variable is set to the value of --out-dir when build.rs is executed.](#6790 (comment)) > [I understand that the worry is that there could be confusion between --out-dir for cargo and the environment variable OUT_DIR for build.rs, but doesn't it mean exactly the same in both cases?](#6790 (comment)) > [--out-dir: Things will be built into $PWD/target as normal, but copies some of the artifacts into the directory specified by out-dir (not a profile specific subdirectory). Unstable flag, added in March 2018. cargo build --out-dir #5203 Ability to specify output artifact name #4875. **Mimicks the behavior of OUT_DIR.**](#6100 (comment)) > [I recently had a couple of people express an interest in --out-dir being stabilized and from my initial digging it seems like what they may actually want is to switch to OUT_DIR, which is already stable.](#6100 (comment))
I noticed that
cargo build
has two subcommands, both added this year. I believe this accurately describes their behavior:--target-dir
: Replaces$PWD/target
with this directory (e.g. a debug build will be built intotarget-dir/debug
). Stable flag, added in April 2018. Add target directory parameter --target-dir #5393 In addition to CARGO_TARGET_DIR env var, support --target-dir command line option #5308. Mimicks the behavior ofCARGO_TARGET_DIR
--out-dir
: Things will be built into$PWD/target
as normal, but copies some of the artifacts into the directory specified byout-dir
(not a profile specific subdirectory). Unstable flag, added in March 2018. cargo build --out-dir #5203 Ability to specify output artifact name #4875. Mimicks the behavior ofOUT_DIR
.(I'm not 100% certain I've accurately described their behavior in relationship to the profile specific subdirectories.)
--out-dir is still unstable, but --target-dir was instantly stabilized (by mistake, I believe).
I can't help but notice that these two flags do very similar things! They also seem to have been designed for very similar purposes (build integration, the meson project is mentioned specifically in both of them).
I'm not certain I agree that either of them should have been added as flags (an argument is made that flags are better than env vars, and while I agree in principle for user oriented APIs, I don't think that build system integration is a user oriented API in the relevant sense), but I'm definitely suspicious of having both of these very similar flags provided. Since target-dir is stable, I'm not sure if there's an available avenue to unify these flags other than just only providing target-dir.
cc @rust-lang/cargo
The text was updated successfully, but these errors were encountered: