3.1 KiB
+++ title = "Setup" +++
Installing Rust
Before installing Rustlings, you must have the latest version of Rust installed. Visit www.rust-lang.org/tools/install for further instructions. This will also install Cargo, Rust's package/project manager.
🐧 If you are on Linux, make sure you have
gccinstalled (for a linker).Debian:
sudo apt install gcc
Fedora:sudo dnf install gcc
🍎 If you are on MacOS, make sure you have Xcode and its developer tools installed:
xcode-select --install
Installing Rustlings
The following command will download and compile Rustlings:
cargo install rustlings
{% details(summary="If the installation fails…") %}
- Make sure you have the latest Rust version by running
rustup update - Try adding the
--lockedflag:cargo install rustlings --locked - Otherwise, please report the issue
{% end %}
Warning: Don't try to clone the repository to do the exercises! rust-analyzer won't
work in that case. Please follow the instructions above instead.
{% details(summary="Why?") %}
The intended way to run Rustlings is to install the binary and run rustlings init as
described in the installation/initialization sections. This generates a Cargo.toml
(different than what you see in the repository) that includes each exercise as a
separate binary target which is enough for rust-analyzer to work.
If you just clone the repository and try to run and edit the exercises directly, the language server will not work.
{% end %}
Initialization
After installing Rustlings, run the following command to initialize the rustlings/ directory:
rustlings init
{% details(summary="If the command rustlings can't be found…") %}
You are probably using Linux and installed Rust using your package manager.
Cargo installs binaries to the directory ~/.cargo/bin.
Sadly, package managers often don't add ~/.cargo/bin to your PATH environment variable.
- Either add
~/.cargo/binmanually toPATH - Or uninstall Rust from the package manager and install it using the official way with
rustup
{% end %}
Now, go into the newly initialized directory and launch Rustlings for further instructions on getting started with the exercises:
cd rustlings/
rustlings
Working environment
Editor
Our general recommendation is VS Code with the rust-analyzer plugin. But any editor that supports rust-analyzer should be enough for working on the exercises.
Terminal
While working with Rustlings, please use a modern terminal for the best user experience. The default terminal on Linux and Mac should be sufficient. On Windows, we recommend the Windows Terminal.
Usage
After being done with the setup, visit the usage page for some info about using Rustlings 🚀