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

Option to use alternate build directory for rust-analyzer #24

Open
timboudreau opened this issue Jun 24, 2024 · 1 comment
Open

Option to use alternate build directory for rust-analyzer #24

timboudreau opened this issue Jun 24, 2024 · 1 comment

Comments

@timboudreau
Copy link

I have a workspace with ~30 crates in it; cargo check can sometimes take quite a while. So, doing an edit and then attempting to build in a shell often means the build is blocked waiting on cargo check to release the lock on the build directory.

A simple solution would be to have the check use a different build directory, so local builds and whatever the Rust plugin wants to do simply can't collide.

It appears that is doable, with some caveats:

  • It looks like the directory must be an absolute path
    • But you can apparently pass a path, e.g. --target-dir" "/tmp/foo
  • There is an open, unassigned issue to solve that here

Despite that, it looks as if it might work to simply point the analyzer at, say, /tmp/$WORKSPACE_PATH_HASH (some short name derived from the workspace path to avoid collisions) or something like that.

Or it might be possible to simply ensure that, while cargo check uses the configuration of the debug profile (or whatever) it doesn't use $TARGET/debug for whatever it wants to write.

Could be implemented as an enablable option to use a $TMP subdir and just ensure the subdir exists before calling it; or as an option to pass arguments or env vars when calling cargo check - although that might be problematic, since if someone did that, every Rust project would try to use the same directory (unless you want to implement some sort of variable dereferencing in the settings).

Anyway, it appears solvable, and would make a big difference in productivity for anyone who winds up waiting several minutes for cargo check for their build/test/whatever to run.

@panekj
Copy link
Contributor

panekj commented Jun 24, 2024

You can use custom command directly in rust-analyzer, no need to implement anything here

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