How to install Rust in Windows under WSL - Tutorial

If you're looking to develop Rust applications on Windows, one of the best ways to set up your environment is by using WSL (Windows Subsystem for Linux). WSL gives you a full Linux (Ubuntu) experience directly inside Windows, making it ideal for Rust development.

In this tutorial, we'll walk you through step-by-step how to install Rust inside your WSL environment. Whether you're completely new to WSL, or just want a clean Rust setup, this guide will have you up and running in no time. We'll cover installing WSL, setting up your Linux (Ubuntu) distribution, and installing Rust.

Tutorial

Instructions

Install Ubuntu with wsl

Check the previous installed ubuntus

wsl --list --verbose
# wsl --unregister Ubuntu-22.04 if exists
wsl --install Ubuntu-22.04

#Enter username: hatari password:labs


Update essential packages

sudo apt update
sudo apt install build-essential


Install Rust & Cargo using rustup

Remove previous rust versions

sudo apt remove --purge rustc cargo
sudo apt autoremove --purge

Open a terminal, then run:

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

Press Enter

Activate Rust in your current terminal

source $HOME/.cargo/env

Test

rustc --version
cargo --version
Comment

Saul Montoya

Saul Montoya es Ingeniero Civil graduado de la Pontificia Universidad Católica del Perú en Lima con estudios de postgrado en Manejo e Ingeniería de Recursos Hídricos (Programa WAREM) de la Universidad de Stuttgart con mención en Ingeniería de Aguas Subterráneas y Hidroinformática.

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.