-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Set IS_RUST_ANALYZER=1
for build commands
#15115
Conversation
I'm curious but are there problems with just setting |
Yeah, that's what we're doing now, but (AFAIK) there's no way to automatically configure that setting for all contributors on repo clone, they need to manually configure it. it seems like the sort of thing that naturally belongs in rust-analyzer itself instead of each project needing to reinvent the wheel and nag everyone to fix their editor configuration. |
This would cause alternating between a rust-analyzer invoked cargo check and a user build to rebuild the build script and everything that depends on it ever time, right?
You can set all rust-analyzer configurations in a |
I'm not familiar enough with how rust-analyzer interacts with the workspace to know—does rust-analyzer produce intermediates that other cargo commands can use? In that case, at the risk of making the change more involved, maybe this could be an opt-in behavior from the build script in some way? Or, instead of an environment variable, the build script could signal "skip running me entirely if you're rust-analyzer and cache nothing so I'll be re-run correctly by cargo"?
Only if the entire team uses VSCode :-) We're split between {Neo,}vim, Emacs, vscode, Jetbrains... plus we sometimes roll with person-specific workspace settings, for example setting the rust-analyzer target to wasm32 when working on the wasm parts of our code, and I think that approach would overwrite those personal settings? |
Rust-analyzer uses plain |
Coming back to this finally (sorry for the silence), I am actually wondering now how cargo handles env changes here. Does it automatically track any env vars that are queried via the corresponding compile time macros? That aside, I do think this is the wrong way to tackle this. The ideal solution I can see is that we finally get a minimal |
For |
I'll close this, I think the |
We have some builds scripts that do heavy work (e.g., running
wasm-pack
) that isn't necessary for RA's analysis, but nonetheless slows down IDE startup because RA runs the build script on server restart^1. We want to add something essentially like this to our build script:But right now there isn't a great way to detect RA in a build script. Based on current main, our build script actually looks like this:
Where
RA_RUSTC_WRAPPER
is set for some invocations, but for full coverage you need to manually addIS_RUST_ANALYZER
tocargoExtraEnv
in your editor's rust-analyzer config. This PR simply unconditionally sets that environment variable.Bikeshedding welcome on the variable name, I just picked what seemed reasonable. There's also the question of documentation, tests, etc.—this is my first RA PR so (if people want to see this merged), I'd appreciate guidance on how to do that.
^1 : We do emit the appropriate
cargo:rerun-if-changed
directives, but that doesn't help when switching branches causes genuine changes in those directories.