Skip to content

Make the error messaging for cargo install aware of build.build-dir#16623

Merged
epage merged 2 commits intorust-lang:masterfrom
jakubadamw:issue-16622
Feb 11, 2026
Merged

Make the error messaging for cargo install aware of build.build-dir#16623
epage merged 2 commits intorust-lang:masterfrom
jakubadamw:issue-16622

Conversation

@jakubadamw
Copy link
Contributor

@jakubadamw jakubadamw commented Feb 10, 2026

When cargo install fails to compile a binary, it produces the following error output:

error: could not compile `issue-16622` (bin "issue-16622") due to 1 previous error
error: failed to compile `issue-16622 v0.0.0 ([…]/issue_16622)`, intermediate artifacts can be found at `[…]/issue_16622/target`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

which currently points to the target directory when discussing intermediate artifacts that can be reused in future reattempts.

However, intermediate artifacts are stored in the directory determined by build.build-dir, so the message should be updated to point to that path and corresponding environment variable instead.

Closes #16622.

@rustbot rustbot added Command-install S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 10, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 10, 2026

r? @ehuss

rustbot has assigned @ehuss.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage, weihanglo

@ranger-ross
Copy link
Member

ranger-ross commented Feb 11, 2026

The changes look good to me.

Would you mind restructuring the commits to be atomic as requested in the contributor guide.
https://doc.crates.io/contrib/process/working-on-cargo.html#submitting-a-pull-request

Ideally, you add the failed_install_points_to_build_dir_for_intermediate_artifacts test in a commit before you make the change so we can see how the output changes.
Note that the tests should run and pass for every commit which the do not currently

```
error: could not compile `issue-16622` (bin "issue-16622") due to 1 previous error
error: failed to compile `issue-16622 v0.0.0 ([…]/issue_16622)`, intermediate artifacts can be found at `[…]/issue_16622/target`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
```

currently points to the target directory.

However, intermediate artifacts are stored in the directory configured by `build.build-dir`,
so the message should be updated to point to that path and corresponding environment variable instead.
@rustbot
Copy link
Collaborator

rustbot commented Feb 11, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@jakubadamw
Copy link
Contributor Author

@ranger-ross, thank you for your review! I addressed your comment and made the commits atomic/self-sufficient.

Copy link
Contributor

@epage epage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@epage epage enabled auto-merge February 11, 2026 13:39
@epage epage added this pull request to the merge queue Feb 11, 2026
Merged via the queue into rust-lang:master with commit 7a566eb Feb 11, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 11, 2026
rust-bors bot pushed a commit to rust-lang/rust that referenced this pull request Feb 12, 2026
Update cargo submodule

8 commits in 0c9e687d237ff04b53ccb67b4ce63e9483789e88..ce69df6f72a3b6a2b5c722ba68ddef255344b31c
2026-02-11 05:58:30 +0000 to 2026-02-12 12:39:45 +0000
- fix: apply `host.runner` only when `host-config` enabled (rust-lang/cargo#16631)
- fix(cli): Improve bad manifest error  (rust-lang/cargo#16630)
- fix: Adjust casing of error message (rust-lang/cargo#16625)
- Enable triagebot new `[view-all-comments-link]` feature (rust-lang/cargo#16629)
- test(help): snapshot cargo help tests (rust-lang/cargo#16626)
- Suggest a `workspace.members` entry even from outside the workspace root (rust-lang/cargo#16616)
- Reorganize build unit directory layout for new build-dir layout (rust-lang/cargo#16542)
- Make the error messaging for `cargo install` aware of `build.build-dir` (rust-lang/cargo#16623)
@rustbot rustbot added this to the 1.95.0 milestone Feb 12, 2026
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Feb 13, 2026
Update cargo submodule

8 commits in 0c9e687d237ff04b53ccb67b4ce63e9483789e88..ce69df6f72a3b6a2b5c722ba68ddef255344b31c
2026-02-11 05:58:30 +0000 to 2026-02-12 12:39:45 +0000
- fix: apply `host.runner` only when `host-config` enabled (rust-lang/cargo#16631)
- fix(cli): Improve bad manifest error  (rust-lang/cargo#16630)
- fix: Adjust casing of error message (rust-lang/cargo#16625)
- Enable triagebot new `[view-all-comments-link]` feature (rust-lang/cargo#16629)
- test(help): snapshot cargo help tests (rust-lang/cargo#16626)
- Suggest a `workspace.members` entry even from outside the workspace root (rust-lang/cargo#16616)
- Reorganize build unit directory layout for new build-dir layout (rust-lang/cargo#16542)
- Make the error messaging for `cargo install` aware of `build.build-dir` (rust-lang/cargo#16623)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cargo install's "intermediate artifacts can be found at" message on failure is incorrect if a custom build.build-dir is configured

5 participants