Skip to content

Latest commit

 

History

History
171 lines (119 loc) · 5.41 KB

setup.md

File metadata and controls

171 lines (119 loc) · 5.41 KB

Preparations Before Workshop

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 your PATH. The editor setup is on your shoulder.

  • 2. DevContainer: Using a development container with podman or docker (best in VS Code) which includes all bells and whistles. Nothing has to be setup. Just launch code and enter the DevContainer.

  • 3. Manual Setup: Install the tools yourself on the system of your choice (not recommended).

1. Nix Development Shell

Installing Nix

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 -- install

Follow their instruction for more information.

Entering the Development Shell

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.

2. Dev Container Setup

Open code and use Reopen in Container to enter the .devcontainer workspace.

3. Manual Setup

Rust and Cargo

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 -V

The 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:

Rustfmt and Clippy

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 fmt

To run clippy:

cargo clippy

More info:

Command Runner

You should install just (a Makefile alternative which is more sane) on your system to make working with these exercises more convenient.

Language Server rust-analyzer

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.

Visual Studio Code

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:

Testing the Setup

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.