Skip to content

Commit

Permalink
Add message on reusing previous temporary path on failed cargo installs
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusGrass committed Jun 4, 2023
1 parent 57326f5 commit 073a32b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
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 `{}`, to 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
4 changes: 3 additions & 1 deletion 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
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`, to 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 \
`[..]`, to 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
6 changes: 4 additions & 2 deletions tests/testsuite/required_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,8 @@ 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 +679,8 @@ Caused by:
"\
[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 Down

0 comments on commit 073a32b

Please sign in to comment.