I wanted to use Ruby on Rails with good tooling on my Windows computer, which made WSL2 the obvious choice. I thought I'd just fire up an Ubuntu VM and off I go. I came across some issues though. There are many tools missing when you just start up.
Here I'll step you through how to get RoR working in WSL2. This guide presumes you already have WSL2 set up on your computer. I'll be starting with a fresh Ubuntu distro.
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get install git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
.bashrc
filegit clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
.bashrc
file. Then reload the shell.rbenv install 2.7.1
rbenv global 2.7.1
ruby -v
gem install rails
rails -v
I've created a gist if you just want to run the script and get up-and-running.

And what's the coolest part of this? You can type code .
in the folder you want to develop, and VSCode will fire up on your Windows computer and automatically connect to the Windows subsystem! How cool is that?