Setting up Win10 and WSL2 for Development July 21, 2020
Setting Up WSL 2 & Rust on Windows 10
I've never been super-keen on doing development on Windows machines.
With WSL aka Windows Subsystem for Linux, there's the possibility of developing on a Windows machine with Windows apps... but with all the Linux goodness.
WSL 2 is the new-to-2020 version that uses the native Linux filesystem (very fast) and has a bunch of other goodies that makes the Windows 10/Linux integration really nice.
I've also been working on Mesa X... a re-imagination of spreadsheets written in Rust (for the server) and TypeScript (front end).
Here's my development setup.
Install WSL 2
First, you have to install WSL 2 on your Win10 machine.
From PowerShell in Administrator mode, type:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Next, restart your machine.
Next, enabled WSL 2:
wsl --set-default-version 2
You may be prompted to download a Linux Kernel patch.
Install Ubuntu 20.04
Next, open the "
Microsoft Store," search for "
Ubuntu 20.04," and install it. Also, install the "
application (it's worlds better than the old DOS-derived terminal.)
Launch the Ubuntu app. You'll be prompted for a username and password. Enter your favorite username (mine is "
and a password.
You'll be doing a lot of
git and doing other stuff.
and like using
To update the packages and install
git and editors, type:
sudo apt update && sudo apt upgrade -y && sudo apt install -y keychain emacs vim git
vim .ssh/id_rsa .ssh/id_rsa.pub and ensure that the directory is only readable by you:
chmod -R og-rwx .ssh/
~/.bashrc adding the following at the end of the file:
/usr/bin/keychain --nogui $HOME/.ssh/id_rsa source $HOME/.keychain/$HOSTNAME-sh
Exit the Ubuntu window and then open a Windows Terminal session to Ubuntu. You should be greeted with a prompt to enter your ssh key's password:
* keychain 2.8.5 ~ http://www.funtoo.org * Starting ssh-agent... * Adding 2 ssh key(s): /home/dpp/.ssh/id_rsa Enter passphrase for /home/dpp/.ssh/id_rsa: * ssh-add: Identity added: /home/dpp/.ssh/id_rsa
To test if this works, try cloning a repo (assuming the ssh key is your GitHub key):
git clone firstname.lastname@example.org:mesa-x/spreadsheet.git mesax
Installing Rust, Dev Tools, etc.
Install Rust with RustUp:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Then make sure you've included the updated environment variables:
source $HOME/.cargo/env and add
to the end of your
Install other stuff that's needed:
sudo apt install -y build-essential npm protobuf-compiler
Can you build Mesa X?
In the step above, you checked out the Mesa X source. Now,
Check out the tag used in this blog post:
git switch -c for_blog
To make sure Rust works, type
cargo test. The Rust code should build.
cd mesa-client and install the npm dependencies:
npm install and check to see if you can
protoc (the stuff that compiles protocol buffer files):
npm run protoc. If all that works,
start the npm app:
npm start and your Windows browser should open to the application.
Using VS Code
Visual Studio Code is currently (July 2020) the hotness in IDEs.
If you've got VS Code installed in Windows-land, just type
code . in the
and you should get VS Code running in Windows... but editing your WSL-based code.
Have fun with a very nice Windows/Linux development experience!