diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index 5f843e8c731..8ddfa4fab3d 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -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() ) diff --git a/tests/testsuite/directory.rs b/tests/testsuite/directory.rs index 0e28de03942..e72f1f07d13 100644 --- a/tests/testsuite/directory.rs +++ b/tests/testsuite/directory.rs @@ -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 @@ -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\"` diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index 2609d804819..0f6d9909a42 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -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(); @@ -2264,7 +2265,9 @@ 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, ) @@ -2272,7 +2275,7 @@ fn failed_install_retains_temp_directory() { // 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()); diff --git a/tests/testsuite/required_features.rs b/tests/testsuite/required_features.rs index ac6c9d23335..88be89fd4d0 100644 --- a/tests/testsuite/required_features.rs +++ b/tests/testsuite/required_features.rs @@ -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` @@ -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`