GNOME Builder and Rust
I have been doing some stuff in GNOME Builder. It works well for C, C++, Vala. But I can't get rust-analyzer
to work to make editing Rust in GNOME Builder comfortable.
I tried several stuffs like changing between nightly and stable Rust channel. Updating my toolchain. Specifying Rust-related paths to flatpak permission (I have GNOME Builder installed via Flatpak). And so on.
After wandering around the Builder editor, I started to understand a bit more of how GNOME Builder builds a project. It has 3 environments, host, build, and runtime. If I run which rust-analyzer
from the terminal, it actually runs on the host environment, which is the same with running a terminal elsewhere.
I find that the build and runtime environment cannot access environment variables that exist on the host. I tested some stuff like running which rust-analyzer
or echo $PATH
on build env (with the fancy CTRL+RETURN command bar) and it returns nothing.
Turns out I just have to go to build configuration, on the environment tab, create new environment on the build environment with name PATH and its value to anywhere rust-analyzer
located. Or simply copy what's already on $PATH in host env.
Restarted Builder and then rust-analyzer
works! I've been writing several files without code suggestions, ahahah.