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

All dependencies recompiled if there is an error during "cargo install <crate>" #4890

Closed
vezaynk opened this issue Jan 2, 2018 · 2 comments · Fixed by #12231
Closed

All dependencies recompiled if there is an error during "cargo install <crate>" #4890

vezaynk opened this issue Jan 2, 2018 · 2 comments · Fixed by #12231
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-install E-easy Experience: Easy S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.

Comments

@vezaynk
Copy link

vezaynk commented Jan 2, 2018

I am running cargo install letsencrypt-rs and every time there is an issue with a dependency (Needed to install make, etc), the process was killed and when I tried again it would recompile every single one of the dependencies.

This is bad because the compiled dependencies should be instead reused as it takes a ton of time, much more so when there is seemingly a hundred dependencies.

There's probably a more minimal way to reproduce it but one way is to take a system without make, run cargo install letsencrypt-rs, after a certain dependency it will fail and make you restart all over again.

@alexcrichton alexcrichton added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Jan 3, 2018
@sputnick1124
Copy link

A reasonable workaround for this is to set the environment variable CARGO_TARGET_DIR to someplace you'd like to store the intermediate artifacts. This will tell cargo to cache all of the successfully built products in said directory and reuse them on subsequent builds.

If the CARGO_TARGET_DIR is not set, when you run cargo install <doomed-to-fail>, cargo will nonetheless report something like:

error: failed to compile `doomed-to-fail v0.1`, intermediate artifacts can be found at '/some/tmp/directory'

After fixing your dependencies, you can run CARGO_TARGET_DIR=/some/tmp/directory cargo install hopefully-this-works and cargo will find the intermediates from the previously failed attempt.

Tested with version 1.31.0. HTH.

@weihanglo
Copy link
Member

weihanglo commented May 24, 2023

sputnick1124 is pretty much correct I believe. To improve, we could tell people do what sputnick1124 has taught in the error message, like:

error: failed to compile `doomed-to-fail v0.1`, intermediate artifacts can be found at '/some/tmp/directory'
    To reuse those artifacts, set the environment variable `CARGO_TARGET_DIR` to that path.

There code lives here:

format!(
"failed to compile `{}`, intermediate artifacts can be \
found at `{}`",
self.pkg,
self.ws.target_dir().display()
)

@weihanglo weihanglo added E-easy Experience: Easy A-diagnostics Area: Error and warning messages generated by Cargo itself. S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing. labels May 24, 2023
@bors bors closed this as completed in b8402be Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-install E-easy Experience: Easy S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants