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

Add message on reusing previous temporary path on failed cargo installs #12231

Merged
merged 2 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/cargo/ops/cargo_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,9 @@ impl<'cfg, 'a> InstallablePackage<'cfg, 'a> {

format!(
"failed to compile `{}`, intermediate artifacts can be \
found at `{}`",
found at `{}`.\nTo reuse those artifacts with a future \
compilation, set the environment variable \
`CARGO_TARGET_DIR` to that path.",
self.pkg,
self.ws.target_dir().display()
)
Expand Down
8 changes: 6 additions & 2 deletions tests/testsuite/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ fn simple_install_fail() {
.with_status(101)
.with_stderr(
" Installing bar v0.1.0
error: failed to compile `bar v0.1.0`, intermediate artifacts can be found at `[..]`
error: failed to compile `bar v0.1.0`, intermediate artifacts can be found at `[..]`.
To reuse those artifacts with a future compilation, set the environment variable \
`CARGO_TARGET_DIR` to that path.

Caused by:
no matching package found
Expand Down Expand Up @@ -759,7 +761,9 @@ fn version_missing() {
.with_stderr(
"\
[INSTALLING] bar v0.1.0
error: failed to compile [..]
error: failed to compile [..], intermediate artifacts can be found at `[..]`.
To reuse those artifacts with a future compilation, set the environment variable \
`CARGO_TARGET_DIR` to that path.

Caused by:
failed to select a version for the requirement `foo = \"^2\"`
Expand Down
9 changes: 6 additions & 3 deletions tests/testsuite/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,8 @@ fn compile_failure() {
"\
[ERROR] could not compile `foo` (bin \"foo\") due to previous error
[ERROR] failed to compile `foo v0.0.1 ([..])`, intermediate artifacts can be \
found at `[..]target`
found at `[..]target`.\nTo reuse those artifacts with a future compilation, \
set the environment variable `CARGO_TARGET_DIR` to that path.
",
)
.run();
Expand Down Expand Up @@ -2264,15 +2265,17 @@ fn failed_install_retains_temp_directory() {
)
.unwrap();
compare::match_contains(
"error: failed to compile `foo v0.0.1`, intermediate artifacts can be found at `[..]`",
"error: failed to compile `foo v0.0.1`, intermediate artifacts can be found at \
`[..]`.\nTo reuse those artifacts with a future compilation, set the environment \
variable `CARGO_TARGET_DIR` to that path.",
&stderr,
None,
)
.unwrap();

// Find the path in the output.
let start = stderr.find("found at `").unwrap() + 10;
let end = stderr[start..].find('\n').unwrap() - 1;
let end = stderr[start..].find('.').unwrap() - 1;
let path = Path::new(&stderr[start..(end + start)]);
assert!(path.exists());
assert!(path.join("release/deps").exists());
Expand Down
7 changes: 5 additions & 2 deletions tests/testsuite/required_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,9 @@ Consider enabling some of the needed features by passing, e.g., `--features=\"a\
"\
[INSTALLING] foo v0.0.1 ([..])
[ERROR] failed to compile `foo v0.0.1 ([..])`, intermediate artifacts can be found at \
`[..]target`
`[..]target`.
To reuse those artifacts with a future compilation, set the environment \
variable `CARGO_TARGET_DIR` to that path.

Caused by:
target `foo` in package `foo` requires the features: `a`
Expand All @@ -678,7 +680,8 @@ Caused by:
"\
[INSTALLING] foo v0.0.1 ([..])
[ERROR] failed to compile `foo v0.0.1 ([..])`, intermediate artifacts can be found at \
`[..]target`
`[..]target`.\nTo reuse those artifacts with a future compilation, set the environment \
variable `CARGO_TARGET_DIR` to that path.

Caused by:
target `foo` in package `foo` requires the features: `a`
Expand Down