Rust-analyzer tries to run build script for the wrong target

Here's the situation as I understand it. All of my rust code for a project lives in one big workspace. Almost all of the code is cross-platform. However, there's one package used by other packages only as a build dependency. But rust-analyzer tries to build it and its dependencies to the currently selected target (aarch64-linux-android in this particular case), not the host target. A build script of one of the dependencies fails, and I end up without code completion, checks and other helpful stuff. Is there a way to mitigate this situation?

1 Like

Does running cargo check from the workspace root work?

No. Judging by the error, I assume it also tries to build this crate for the target platform, not the host platform.

That's basically just what RA is doing, so I would recommend trying to make that work somehow. I don't know if there's any way to exclude the crate from the build while it's in the workspace, so the only idea I can think of is to move it out of the workspace and use a path dependency. You could still have a VSCode workspace that includes both either by putting them into folders next to each other and opening the folder containing them, or by using the rust-analyzer.linkedProjects option.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.