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

Consider not recompiling when PATH env var changes or being smarter about it? #2200

Closed
dsherret opened this issue Dec 27, 2024 · 2 comments
Closed

Comments

@dsherret
Copy link

dsherret commented Dec 27, 2024

This isn't this crate's fault, but I've run into so many issues with different tools changing the PATH causing this crate to recompile. For example:

  1. Open VSCode not via the terminal, compile a project.
  2. Close vscode, open a terminal, run cargo check, this crate recompiles because the PATH is different than what was in vscode.
  3. Run code ., open the built-in terminal, run cargo check... a recompile happens because some extension has injected to the PATH specifically for the terminal. Now rust-analyzer runs, recompiles because the vscode PATH is different than the terminal... then run cargo check in the terminal and recompile happens.

Any chance we could just add an exclusion for PATH here?

ring/build.rs

Line 38 in 4f09fa5

println!("cargo:rerun-if-env-changed={}", name);

@briansmith
Copy link
Owner

I think this is a good idea but I don't think ring's build script is the place to do it.

If you read build.rs you can see that we don't mention $PATH at all. I think it is cc-rs or Cargo itself that forces recompilation when $PATH or any environment variable changes.

I suggest that you write a cargo wrapper that normalizes the entire environment and configure your editor/IDE and other tooling to use this wrapper.

@dsherret
Copy link
Author

dsherret commented Jan 1, 2025

Huh, you're right and sorry for the bother! I wonder why CARGO_LOG=cargo::core::compiler::fingerprint=debug has been saying ring was causing the recompilation on PATH change (and I only have this issue when ring is a dependency). I'll look into it more when it happens again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants