Rust RLS on GNOME Builder | GNOME 3.26

alex285
2 min readNov 1, 2017

--

this is a question i got a few times, plus im demo-ing Builder in some of my videos and people are like “whats this editor!?”

in this post i will very quickly show you how to start with Rust and RLS (Rust Language Server) support in GNOME Builder. check out on links for official & updated documentation!

video is on Arch Linux with JHBuild

get Builder!

first you need to get GNOME Builder. it should be as easy as

sudo apt install gnome-builder

if you are comfortable with Flatpaks or if your Linux doesn’t ship GNOME 3.26, you can get Builder from Flathub

flatpak install --from https://flathub.org/repo/appstream/org.gnome.Builder.flatpakref

get Rustup!

Rustup is Rust’s version manager. if you have Rust installed from your Linux repos, you need to uninstall it. then run

curl https://sh.rustup.rs -sSf | sh

that will prompt you some options. select nightly. while you can still use stable Rust, RLS needs the nightly

if you already have Rustup installed, you can just

rustup install/update nightly

and default it -if you want!

rustup default nightly

to update (that will update both rustup and rust )

rustup update

Builder allows to update Rustup and Rust toolchains from within its interface, but it is better to check on Rustup Github and use CLI

im using Builder 3.27.1+Git and Rust 1.23.0-nightly

get RLS!

once you have Rust nightly installed and updated, you can install RLS

rustup component add rls-preview --toolchain nightly
rustup component add rust-analysis --toolchain nightly
rustup component add rust-src --toolchain nightly

get Racer?

actually you dont need Racer for Builder, but you will need it for other code editors, like VSCode, so it is a good idea to have it

cargo install racer

however RLS needs RUST_SRC_PATH which perhaps is a bug? anyway, to set it

export RUST_SRC_PATH="$(rustc --print sysroot)/lib/rustlib/src/rust/src"

that in my case will be

/home/alex/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src

you can add this on your .zshrc or .bashrc

export RUST_SRC_PATH=$HOME/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src

that was All!

you can now check out Rust docs, Rust book (that book is awesome!) and GTK-RS!

btw Builder should also highlight Rust errors as you type, which for some reason it doesn’t work here :/

--

--