In this section you'll find instructions on how to install the tools we'll use during the course.
All of these tools are available for Linux, macOS and Windows users. We'll need the tools to write and compile our Rust code, and allow for remote mentoring.
Important: These instructions are to be followed before the workshop, before the start of the first tutorial. If you have any problems with installation, contact the lecturers! We won't be addressing installation problems during the first tutorial.
There are 3 setups you can choose from which are described further below. Test the setup in this section when you setup on option.
-
1. Nix Development Shell: A stable development environment with the Nix package manager. The
nix develop './tools/nix#default'in this repository will enter a development shell with the toolchain in yourPATH. The editor setup is on your shoulder. -
2. DevContainer: Using a development container with
podmanordocker(best in VS Code) which includes all bells and whistles. Nothing has to be setup. Just launchcodeand enter the DevContainer. -
3. Manual Setup: Install the tools yourself on the system of your choice (not recommended).
If you have not installed nix on your Linux or macOS use
nix-installer:
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- installFollow their instruction for more information.
If you have the package manager
nix installed you can
enter a development setup easily with
nix develop './tools/nix#default'or just nix-develop or automatically when direnv is
installed and setup for your shell and
direnv allow was executed inside the repository.
Open code and use Reopen in Container to enter the
.devcontainer workspace.
First we'll need rustc, the standard Rust compiler. rustc is generally not
invoked directly, but through cargo, the Rust package manager. rustup takes
care of installing rustc and cargo.
This part is easy: go to https://rustup.rs and follow the instructions. Please make sure you're installing the latest default toolchain. Once done, run
rustc -V && cargo -VThe output should be something like this:
rustc 1.79.0 (129f3b996 2024-06-10)
cargo 1.79.0 (ffa9cf99a 2024-06-03)Using Rustup, you can install Rust toolchains and components. More info:
To avoid discussions, Rust provides its own formatting tool, rustfmt. We'll
also be using clippy, a collection of lints to analyze your code, that catches
common mistakes for you. You'll notice that Rusts clippy can be a very helpful
companion. Both rustfmt and clippy are installed by rustup by default.
To run rustfmt on your project, execute:
cargo fmtTo run clippy:
cargo clippyMore info:
You should install just (a Makefile
alternative which is more sane) on your system to make working with these
exercises more convenient.
To write and learn effectively, you need the rust-analyzer installed. The
installer rustup will provide this too. The setup of rust-analyzer depends
on your editor. With Visual Studio Code (code) it will be setup when following
the section below.
During the course, you are best using Visual Studio Code (code) to write code.
We use code to allow for remote collaboration and mentoring during tutorial
sessions.
You can find the installation instructions here: https://code.visualstudio.com/.
We will install some plugins as well. The first one is Rust-Analyzer. Installation instructions can be found here https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer. Rust-Analyzer provides a lot of help during development and in indispensable when getting started with Rust.
Another plugin we'll install is Live Share. We will use the plugin to share screens and provide help during remote tutorial sessions. The extension pack also contains the Live Share Audio plugin, which allows for audio communication during share sessions. Installation instructions can be found here: https://marketplace.visualstudio.com/items?itemName=MS-vsliveshare.vsliveshare
The last plugin we'll use is CodeLLDB. This plugin enables debugging Rust code from within vscode. You can find instructions here: https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb.
More info:
Run
just run setup
🦀 Hello, world! 🦀
You've successfully compiled and run your first Rust project!
X: 2; Y: 2
If that works meaning it builds and runs the setup binary, you are all set for the exercises.