Rust and Rust Analyzer Notes
Collection of Rust and rust-analyzer application hints and resource references. These hints were tested on Ubuntu 22.04 LTS.
Installing Rust on Linux
Automatic Installation via Rustup
To install rust toolchain:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
To add rust source (required for rust-analyzer):
rustup component add rust-src
To update rust toolchain:
rustup update
To uninstall rust toolchain:
rustup self uninstall
Environment Configuration
Add the following lines to ~/.bashrc
(for interactive shells) and to
~/.profile
(for login shells):
. ~/.cargo/env
Installing Rust Analyzer
From Source Code
To clone and compile rust-analyzer from source:
git clone https://github.com/rust-analyzer/rust-analyzer.git -b release
cd rust-analyzer
cargo xtask install --server # will install rust-analyzer into ~/.cargo/bin
From Pre-Compiled Binary
Download and unpack the latest rust-analyzer release e.g.:
gunzip -vc rust-analyzer-x86_64-unknown-linux-gnu.gz > ~/.cargo/bin/rust-analyzer