<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: sebar</title>
    <description>The latest articles on Forem by sebar (@sebar).</description>
    <link>https://forem.com/sebar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F360977%2F95ba1ace-6c04-4d4f-984c-cfac8ff7448e.png</url>
      <title>Forem: sebar</title>
      <link>https://forem.com/sebar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sebar"/>
    <language>en</language>
    <item>
      <title>How to setup Rails on Windows 10 for remote development</title>
      <dc:creator>sebar</dc:creator>
      <pubDate>Sun, 05 Apr 2020 02:41:31 +0000</pubDate>
      <link>https://forem.com/sebar/how-to-setup-rails-on-windows-10-for-remote-development-1ipa</link>
      <guid>https://forem.com/sebar/how-to-setup-rails-on-windows-10-for-remote-development-1ipa</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;This  guide is meant to help Windows 10 users set up their development&lt;br&gt;
environment for Ruby on Rails application development. This guide touches, among&lt;br&gt;
others, on:&lt;/p&gt;

&lt;ol&gt;
 &lt;li&gt;
 WSL 2 (Windows Subsystem for Linux)&lt;/li&gt;
 &lt;li&gt;Setting up Ruby and Rails&lt;/li&gt;
 &lt;li&gt;Setting up VSCode for local development&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Setting up WSL2 on Windows 10
&lt;/h2&gt;

&lt;p&gt;Reference: &lt;a href="https://docs.microsoft.com/en-us/windows/wsl/wsl2-install"&gt;Install WSL 2 | Microsoft&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first thing you want to do is make sure your Windows 10 version and&lt;br&gt;
build are compatible with WSL2 -- &lt;em&gt;As of April 3, 2020, version 1909,&lt;br&gt;
build 18363.720 is **not&lt;/em&gt;* compatible with WSL. This is the standard&lt;br&gt;
widely distributed version at the moment*&lt;/p&gt;

&lt;p&gt;If by the time you're reading this your windows version is lower than&lt;br&gt;
version 2004, build 19041.153, then you will most likely have to&lt;br&gt;
get into the Windows Insider program to get Windows preview builds,&lt;br&gt;
more information &lt;a href="https://insider.windows.com/en-us/"&gt;on this page&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can check your windows version by typing &lt;code&gt;winver&lt;/code&gt; on the start menu&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mZY0P7Ch--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/winver.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mZY0P7Ch--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/winver.png" width="350" alt="Windows version"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Getting into the Insider Program
&lt;/h3&gt;

&lt;p&gt;If you're not yet in the insider program, you can visit the&lt;br&gt;
following link for very detailed instructions on how to&lt;br&gt;
enroll into Insider Program, and install WSL 2:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://docs.microsoft.com/en-us/windows/wsl/wsl2-install"&gt;Official Microsoft's WSL2 Installation Instructions&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pureinfotech.com/install-windows-subsystem-linux-2-windows-10/"&gt;How to install Windows Subsystem for Linux 2 on Windows 10&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: These guides includes WSL2 installation too&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you want the short version, go to Settings &amp;gt; Update&lt;br&gt;
&amp;amp; Security &amp;gt; Windows Insider Program. There, make sure to get onto the&lt;br&gt;
&lt;strong&gt;SLOW ring&lt;/strong&gt;. At the time this guide was first written, you don't need&lt;br&gt;
 get into the Fast ring, so let's avoid unnecessary problems.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NmWO5GhW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/insider1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NmWO5GhW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/insider1.png" width="650" alt="Enroll into insider preview"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After getting into the Slow ring, restart your PC if&lt;br&gt;
required. Then, check windows for updates on Settings &amp;gt;&lt;br&gt;
Uptade &amp;amp; Security &amp;gt; Windows Update. &lt;strong&gt;Once your Windows&lt;br&gt;
build is above build 18917, you can continue.&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Installing WSL2
&lt;/h3&gt;

&lt;p&gt;Now that you have the right OS build, you can enable WSL2&lt;br&gt;
on your computer &lt;strong&gt;manually&lt;/strong&gt; or &lt;strong&gt;via Poweshell&lt;/strong&gt;:&lt;/p&gt;
&lt;h4&gt;
  
  
  Powershell instructions
&lt;/h4&gt;

&lt;p&gt;Open up Powershell as Admin by right clicking the Windows&lt;br&gt;
start button and selecting "Windows Powershell (Admin)".&lt;br&gt;
Then, paste and run the following commands and restart your computer&lt;br&gt;
after they are done running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nf"&gt;dism.exe&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/online&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/enable-feature&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/featurename:Microsoft-Windows-Subsystem-Linux&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/all&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/norestart&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nf"&gt;dism.exe&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/online&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/enable-feature&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/featurename:VirtualMachinePlatform&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/all&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/norestart&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Manual instructions
&lt;/h4&gt;

&lt;p&gt;Go to Windows' start menu, and type "Turn Windows features&lt;br&gt;
on or off". If you click in the right item, you'll see the&lt;br&gt;
window below. Make sure to check "Windows Subsystem for&lt;br&gt;
Linux"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--f_pwPQPs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/winfeatures.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--f_pwPQPs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/winfeatures.png" width="400" alt="Turn on WSL feature"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You'll probably be asked to restart your PC, please do so now.&lt;br&gt;
After enabling Windows Subsystem for Linux, then we have to&lt;br&gt;
install a Linux &lt;em&gt;distro&lt;/em&gt; (short for distribution). Open up&lt;br&gt;
the Windows Store app, and search for "Linux". You should&lt;br&gt;
see something like the image below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m7W5xQDu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/winstore.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m7W5xQDu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/winstore.png" width="600" alt="Linux subpage on Windows Store"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install "Ubuntu" from the linux subpage. It will take a few&lt;br&gt;
seconds. After it is installed, launch it. You will see a&lt;br&gt;
&lt;em&gt;terminal&lt;/em&gt; window showing the following message:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;Installing, this may take a few minutes...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You will be asked to create a default UNIX user account.&lt;br&gt;
Make sure it is a simple username (avoid mayus, symbols,&lt;br&gt;
etc). Then type a password (&lt;em&gt;no characters will show&lt;br&gt;
while you type, so make sure you get it right!&lt;/em&gt;) and&lt;br&gt;
confirm it. If everything went according to plan, you&lt;br&gt;
should see the following message:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Installation successful!

To run a command as administrator (user "root"), use
"sudo `&amp;lt;command&amp;gt;`".

See "man sudo_root" for details.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Congratulations! You are now running a virtual Linux inside&lt;br&gt;
Windows 10. If anything didn't go as expected, Google the&lt;br&gt;
error messages you get until everything is going as expected.&lt;br&gt;
Assuming you got the right version of Windows 10 running, if you&lt;br&gt;
made a mistake while installing Ubuntu, you can always just uninstall&lt;br&gt;
from the Windows Store and try again. This will reset (almost)&lt;br&gt;
everything related to that Linux distro, so if you seriously mess up,&lt;br&gt;
you can always reset.&lt;/p&gt;
&lt;h4&gt;
  
  
  Making sure WSL version 2 is running
&lt;/h4&gt;

&lt;p&gt;If you still have your Ubuntu &lt;em&gt;bash&lt;/em&gt; terminal open, close it (&lt;em&gt;pro tip:&lt;br&gt;
type &lt;code&gt;exit&lt;/code&gt; instead of clicking the X arrow. Get used to the CLI -&lt;br&gt;
Command Line Interface&lt;/em&gt;). Open Powershell and type&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nf"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-l&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-v&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You should see something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--joLglEGa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/wsllist.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--joLglEGa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/wsllist.png" width="750" alt="Distros list"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If your distro's version is NOT 2, then you definitely have to run the&lt;br&gt;
command below. If it is 2, you should run it anyways just in case:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nf"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--set-version&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Distro&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;2&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Where &lt;code&gt;&amp;lt;Distro&amp;gt;&lt;/code&gt; is your distro's name from the list (mine is "Ubuntu").&lt;br&gt;
You will see online that some people have other names (like Ubuntu 18.04),&lt;br&gt;
don't worry about that for now. If successful, you should see the following&lt;br&gt;
message:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Conversion in progress, this may take a few minutes...

For information on the key differences with WSL 2 please visit &amp;lt;https://aka.ms/wsl2&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Then, run the following command so every next instance is WSL 2 too:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nf"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--set-default-version&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;2&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Run the &lt;code&gt;wsl -l -v&lt;/code&gt; command again and make sure you got version 2 now. If&lt;br&gt;
everything went well, you have finished the WSL 2 setup part.&lt;/p&gt;
&lt;h2&gt;
  
  
  Setting up Ruby on Rails
&lt;/h2&gt;

&lt;p&gt;Now you have to update your Linux distro and set up Rails. For detailed and&lt;br&gt;
up-to-date instructions, you can visit &lt;a href="https://gorails.com/setup/windows/10#ruby"&gt;Rails Installation Tutorial&lt;/a&gt;;&lt;br&gt;
I recommend that you follow the steps outlined in this site and select all&lt;br&gt;
recommended options and don't skip any steps! You will need everyhing done&lt;br&gt;
here at some point or another. Most of the guide works, although some parts&lt;br&gt;
may not work for you as time passes and different packages get updated. &lt;strong&gt;For&lt;br&gt;
instance, at this time, the installation instruction for PostgreSQL from&lt;br&gt;
the tutorial above doesn't work&lt;/strong&gt; (I show how to do this below).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; when pasting lines of code into your Ubuntu bash terminal, CTRL+V&lt;br&gt;
won't work, but if you right-click the terminal it will paste the content&lt;br&gt;
from your clipboard.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip 2:&lt;/strong&gt; If this is your first time using the terminal, it's best if you&lt;br&gt;
paste commands 1 line at a time. Multi-line should work, but you may make&lt;br&gt;
mistakes as sometimes the last line doesn't run automatically.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Drl0LTSH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/gorails1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Drl0LTSH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/gorails1.png" width="700" alt="GoRails example"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
 &lt;em&gt;GoRails tutorial example&lt;/em&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;p&gt;As you follow the steps above, make sure to read the return messages from&lt;br&gt;
the terminal. If there's anything funky or you get an error message, stop&lt;br&gt;
and debug it! The order in which things are done makes a big difference.&lt;/p&gt;

&lt;p&gt;Just in case the guide above changes, I will show the instructions for Ruby&lt;br&gt;
version 2.7.1 and Rails version 6.0.2.2 below, with some handy tips for&lt;br&gt;
beginners.&lt;/p&gt;
&lt;h3&gt;
  
  
  Installing Ruby and Updating your Distro
&lt;/h3&gt;

&lt;p&gt;Ruby is the backend language that powers Rails apps. This means that it&lt;br&gt;
controls the logic via scripts, just like Python or R. You can learn more&lt;br&gt;
about this &lt;a href="https://www.ruby-lang.org/en/about/"&gt;here&lt;/a&gt; and &lt;a href="https://ruby-lang.co/what-is-ruby/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;First, let's get your distro upgraded! In Linux speech, "update" means&lt;br&gt;
getting the latest version numbers, and "upgrade" means actually downloading&lt;br&gt;
and installing them. Run the following code in Ubuntu:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt dist-upgrade &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get autoremove &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo
&lt;/span&gt;apt-get clean
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you are asked to proceed, type "Y" and hit enter&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Vf1t99bb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/fstupdate.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Vf1t99bb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/fstupdate.png" width="750" alt="First upgrade"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that your distro's libraries are up-to-date, let's proceed to install&lt;br&gt;
ruby. Run the following 2 lines in your Ubuntu terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;curl
curl &lt;span class="nt"&gt;-sL&lt;/span&gt; https://deb.nodesource.com/setup_12.x | &lt;span class="nb"&gt;sudo&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; bash -
curl &lt;span class="nt"&gt;-sS&lt;/span&gt; https://dl.yarnpkg.com/debian/pubkey.gpg | &lt;span class="nb"&gt;sudo &lt;/span&gt;apt-key add -
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"deb https://dl.yarnpkg.com/debian/ stable main"&lt;/span&gt; | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; /etc/apt/sources.list.d/yarn.list

&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get update

&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install &lt;/span&gt;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
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;That's a long code! If you are promped for your password, please input it&lt;br&gt;
and press enter. This is because we invoked sudo (&lt;em&gt;pro tip: sudo won't ask&lt;br&gt;
you for a password for some time after inputting it successfully&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;Now, let;s install Ruby using &lt;code&gt;rbenv&lt;/code&gt;. Run the following lines in your&lt;br&gt;
bash terminal (same Ubuntu window):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd
&lt;/span&gt;git clone https://github.com/rbenv/rbenv.git ~/.rbenv
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'export PATH="$HOME/.rbenv/bin:$PATH"'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.bashrc
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'eval "$(rbenv init -)"'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.bashrc
&lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nv"&gt;$SHELL&lt;/span&gt;

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.bashrc
&lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nv"&gt;$SHELL&lt;/span&gt;

rbenv &lt;span class="nb"&gt;install &lt;/span&gt;2.7.1
rbenv global 2.7.1
ruby &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now let's install bundler, which is an impotant gem (ruby libary):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;gem &lt;span class="nb"&gt;install &lt;/span&gt;bundler
rbenv rehash
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Configuring Git
&lt;/h3&gt;

&lt;p&gt;If you don't already have a GitHub account, &lt;a href="https://github.com/join?source=header-home"&gt;create one now&lt;/a&gt;.&lt;br&gt;
This will come very handy in the future, and some things we do here (like&lt;br&gt;
creating SSH keys) will be useful outside of Git and Github, so no skipping.&lt;/p&gt;

&lt;p&gt;After creating your Github account (or if you already had one), paste the&lt;br&gt;
following commands in your terminal, replaceing the items in CAPS with your&lt;br&gt;
name (use your UNIX username for simplicity) and github email:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; color.ui &lt;span class="nb"&gt;true
&lt;/span&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.name &lt;span class="s2"&gt;"YOUR NAME"&lt;/span&gt;
git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.email &lt;span class="s2"&gt;"YOUR@EMAIL.com"&lt;/span&gt;
ssh-keygen &lt;span class="nt"&gt;-t&lt;/span&gt; rsa &lt;span class="nt"&gt;-b&lt;/span&gt; 4096 &lt;span class="nt"&gt;-C&lt;/span&gt; &lt;span class="s2"&gt;"YOUR@EMAIL.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;When prompted for a location, just press enter. Same for password, no need&lt;br&gt;
to add a password to this for now. If successful, this is a sample output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Generating public/private rsa key pair.
Enter file in which to save the key (/Users/USERNAME/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/USERNAME/.ssh/id_rsa.
Your public key has been saved in /Users/USERNAME/.ssh/id_rsa.pub.
The key fingerprint is:
80:5f:25:7c:f4:90:aa:e1:f4:a0:01:43:4e:e8:bc:f5 vivek@desktop01
The key's randomart image is:
+--[ RSA 2048]----+
| oo    ...+.     |
|.oo  .  .ooo     |
|o .o. . .o  .    |
| o ...+o.        |
|  o .=.=S        |
| .  .Eo .        |
|                 |
|                 |
|                 |
+-----------------+
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We just generated fancy, industrial-grade security keys. This is much more&lt;br&gt;
convenient and secure than using passwords (even though you would never&lt;br&gt;
re-use a password, rigt?). So we'll paste the encrypted PUBLIC key into&lt;br&gt;
Github, which will accept our connections in the future without the need&lt;br&gt;
of a password. Get your public key by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; ~/.ssh/id_rsa.pub
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This will output the contents of the "id_rsa.pub" file, which holds your&lt;br&gt;
SSH public key. Once you get that output, you can select it with your&lt;br&gt;
mouse and right-click it to copy it (remember, CTRL+C doesn't copy things&lt;br&gt;
in the Ubuntu bash terminal).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: the ~ variable is the same as typing \$HOME, which is a variable as&lt;br&gt;
indicated by the preceding dollar sign (\$). This is just a shortcut to&lt;br&gt;
indicate your user's home folder, very similar to your user folder in&lt;br&gt;
Windows 10.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The command's output should look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSU
GPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3
Pbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XA
t3FaoJoAsncM1Q9x5+3V0Ww68/eIFmb1zuUFljQJKprrX88XypNDvjYNby6vw/Pb0rwert/En
mZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbx
NrRFi9wrf+M7Q== USER@HOSTNAME
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now, let's head to &lt;a href="https://github.com/settings/keys"&gt;Github&lt;/a&gt; and paste that&lt;br&gt;
SSH key &lt;a href="https://github.com/settings/ssh/new"&gt;in here&lt;/a&gt;. Remember to give this&lt;br&gt;
key a name so you remember it's your WSL 2 connecting to Github. Let's&lt;br&gt;
double-check that everything worked out, run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh &lt;span class="nt"&gt;-T&lt;/span&gt; git@github.com&lt;span class="sb"&gt;`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You should see something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hi USERNAME! You've successfully authenticated, but GitHub does not provide shell access.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Great! So now we have a) WSL 2 set up, b) an Ubuntu distro installed and&lt;br&gt;
updated, c) Ruby installed, and d) an SSH key pair created and successfully&lt;br&gt;
connected to Github. We're almost there.&lt;/p&gt;
&lt;h3&gt;
  
  
  Installing Rails
&lt;/h3&gt;

&lt;p&gt;Run the following commands in your bash terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-sL&lt;/span&gt; https://deb.nodesource.com/setup_12.x | &lt;span class="nb"&gt;sudo&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; bash -
curl &lt;span class="nt"&gt;-sS&lt;/span&gt; https://dl.yarnpkg.com/debian/pubkey.gpg | &lt;span class="nb"&gt;sudo &lt;/span&gt;apt-key add -
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"deb https://dl.yarnpkg.com/debian/ stable main"&lt;/span&gt; | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; /etc/apt/sources.list.d/yarn.list

&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; nodejs yarn
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This may take a few minutes as you're installing NodeJS and Yarn, two very&lt;br&gt;
important packages.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Note: you may have noticed that whenever we run the&lt;br&gt;
&lt;code&gt;apt update&lt;/code&gt; or &lt;code&gt;apt-get install&lt;/code&gt; commands we get more packages, and&lt;br&gt;
whenever we run &lt;code&gt;gem install&lt;/code&gt; command we get more "gems" (ruby libraries)&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And now we finally install Rails (this may take a few minutes too):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;gem &lt;span class="nb"&gt;install &lt;/span&gt;rails &lt;span class="nt"&gt;-v&lt;/span&gt; 6.0.2.2
rbenv rehash
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let's test it out by running &lt;code&gt;rails -v&lt;/code&gt;, you should get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;rails &lt;span class="nt"&gt;-v&lt;/span&gt;
Rails 6.0.2.2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you get anything different, start debugging/Googling.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing and Configuring PostgreSQL
&lt;/h3&gt;

&lt;p&gt;You can install PostgreSQL in Windows or directly in the WSL. It is easier&lt;br&gt;
to install it in Windows, but I prefer separating my development environment&lt;br&gt;
from my personal user space, so I'll show how to install it in your WSL.&lt;/p&gt;

&lt;p&gt;As of April 3, 2020, installing PostgreSQL-11 isn't trivial. First, let's&lt;br&gt;
go to &lt;a href="https://www.postgresql.org/download/linux/ubuntu/"&gt;Postgre's website&lt;/a&gt;.&lt;br&gt;
Choose your Ubuntu apt repository (most likely Bionic 18.04) and run the&lt;br&gt;
following commands from your bash terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;vim /etc/apt/sources.list.d/pgdg.list
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Vim is the terminal's text editor. &lt;strong&gt;Don't try typing things yet!&lt;/strong&gt; Vim&lt;br&gt;
doesn't start in "insert mode" which is the mode that lets you type stuff,&lt;br&gt;
instaed it starts in the mode that accepts commands. So first push the "i"&lt;br&gt;
key in your keyboard. This will take vim into "insert mode" like below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JAK95-WY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/vimins.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JAK95-WY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/vimins.png" width="750" alt="Vim insert mode"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
 &lt;em&gt;Vim in insert mode -&amp;gt; text editing enabled&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now that we can insert stuff, paste the following line into the&lt;br&gt;
document (remember to right-click)L&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight viml"&gt;&lt;code&gt;deb http&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="sr"&gt;//&lt;/span&gt;apt&lt;span class="p"&gt;.&lt;/span&gt;postgresql&lt;span class="p"&gt;.&lt;/span&gt;org&lt;span class="sr"&gt;/pub/&lt;/span&gt;repos&lt;span class="sr"&gt;/apt/&lt;/span&gt; bionic&lt;span class="p"&gt;-&lt;/span&gt;pgdg main
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sq-_7mNg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/vimpaste.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sq-_7mNg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/vimpaste.png" width="750" alt="Pasted code"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After pasting that line, we have to save and exit. To do this, first&lt;br&gt;
exit INSERT mode by pressing your ESC key. You'll notice that the&lt;br&gt;
-- INSERT -- message disappeared from the bottom left corter of&lt;br&gt;
vim's screen. Now, type &lt;code&gt;:w&lt;/code&gt; and press enter. This will ask vim&lt;br&gt;
to &lt;strong&gt;write&lt;/strong&gt; changes into the file. Then, type &lt;code&gt;:q&lt;/code&gt; which will ask&lt;br&gt;
vim to exit (&lt;em&gt;Note: you can also do &lt;code&gt;:wq&lt;/code&gt; to do both at the same time&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;We just added the information required for bash to successfully get the&lt;br&gt;
latest version of PostgreSQL. So now we'll get it! Run the following&lt;br&gt;
command in bash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;wget &lt;span class="nt"&gt;--quiet&lt;/span&gt; &lt;span class="nt"&gt;-O&lt;/span&gt; - https://www.postgresql.org/media/keys/ACCC4CF8.asc | &lt;span class="nb"&gt;sudo &lt;/span&gt;apt-key add -

&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get update
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We got the update info now, let's install:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install &lt;/span&gt;postgresql-11

&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;libpq-dev
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now that PostgreSQL is installed, let's set up a user. Run the code below&lt;br&gt;
replacing &lt;code&gt;USERNAME&lt;/code&gt; for your UNIX user for simplicity:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; postgres createuser USERNAME &lt;span class="nt"&gt;-s&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And now we're done with PostgreSQL! All that's left is to test the server:&lt;/p&gt;

&lt;h3&gt;
  
  
  Testing Rails server
&lt;/h3&gt;

&lt;p&gt;To see whether things are working, lets boot up a server. Run the following&lt;br&gt;
lines of code in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd
&lt;/span&gt;rails new helloworldapp
&lt;span class="nb"&gt;cd &lt;/span&gt;helloworldapp
rails server &lt;span class="nt"&gt;-b&lt;/span&gt; 0.0.0.0 &lt;span class="nt"&gt;-p&lt;/span&gt; 3000
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6S0ESb7U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/pumaboot.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6S0ESb7U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/pumaboot.png" width="750" alt="Puma server booted"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
 &lt;em&gt;Puma server booted successfully&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now, if you were able to boot up Puma successfully, you&lt;br&gt;
should be able to open up Chrome or any other browser and&lt;br&gt;
enter &lt;code&gt;http://localhost:3000&lt;/code&gt; in the address bar. If you&lt;br&gt;
did everything well, you should see the following page:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yjxsp5PY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/yayrails.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yjxsp5PY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/yayrails.png" width="750" alt="Rails successful"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Rejoice! The hard part is over. &lt;strong&gt;Now, close your server by going back to the&lt;br&gt;
terminal and pressing CTRL+C&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Setting up VSCode for Local Development
&lt;/h2&gt;

&lt;p&gt;It's great that you have a server up and running, but you will most likely&lt;br&gt;
want to have real-time access to the code and assets in the server. The files&lt;br&gt;
that live in your Linux subsystem don't like comingling with your Windows&lt;br&gt;
files (they are completely separate Operating Systems after all). &lt;em&gt;This means&lt;br&gt;
that you can't really edit those files DIRECTLY from Windows&lt;/em&gt;. If we left&lt;br&gt;
things as they are now, you would have to make some code, upload it to&lt;br&gt;
Github, and then download it using your Ubuntu terminal. This would be&lt;br&gt;
cumbersome to say the least.&lt;/p&gt;

&lt;p&gt;Fret not! Since your WSL lives inside Windows, you CAN edit the files using&lt;br&gt;
Windows, but &lt;em&gt;not directly&lt;/em&gt;. This means that you will be able to code and&lt;br&gt;
instantly see the changes you made in the same computer.&lt;/p&gt;

&lt;p&gt;If this sounds a bit too technical, &lt;strong&gt;just follow these steps so you can&lt;br&gt;
use VSCode inside your new Linux environment.&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Download and Install VSCode
&lt;/h3&gt;

&lt;p&gt;In case you don't already have VSCode, then &lt;a href="https://code.visualstudio.com/download"&gt;please download and install it&lt;br&gt;
now&lt;/a&gt; (&lt;em&gt;download the Windows 64 bit&lt;br&gt;
version unless you know you have a different Operating System&lt;/em&gt;). You may be&lt;br&gt;
thinking about downloading the Ubuntu version, but don't. WSL 2 is &lt;em&gt;kind of&lt;/em&gt;&lt;br&gt;
Linux, but not full fledged, VSCode needs to run from a fully functional&lt;br&gt;
Operating System like the Windows 10 you're running now.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Make sure to leave the "Add to PATH" checkbox &lt;strong&gt;TICKED&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Some resources in case something goes wrong:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://code.visualstudio.com/docs/remote/wsl"&gt;Official "Developing in WSL" guide&lt;/a&gt;&lt;br&gt;
&lt;a href="https://code.visualstudio.com/remote-tutorials/wsl/getting-started"&gt;Remote development in WSL guided tutorial&lt;/a&gt;&lt;br&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl"&gt;Remote-WSL Extension site&lt;/a&gt;&lt;br&gt;
&lt;a href="https://devblogs.microsoft.com/commandline/an-in-depth-tutorial-on-linux-development-on-windows-with-wsl-and-visual-studio-code/"&gt;Full guide from Microsoft&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Install Remote Development Extensions
&lt;/h3&gt;

&lt;p&gt;After installing, open VSCode. It will most likely offer you to install a&lt;br&gt;
"Remote-WSL" extension. Don't do it for now. Go to extensions on the left&lt;br&gt;
(or hit CTRL+SHIFT+X) and paste this into the search bar:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Remote Development
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You should see something like the picture below but with&lt;br&gt;
the option to install available (I already have it installed&lt;br&gt;
so it doesn't show up):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bWESXzS9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/remoteext.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bWESXzS9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/remoteext.png" width="500" alt="Remote Extension"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install this one. If you installed it successfully, you should see the little&lt;br&gt;
connection icon in the bottom-left corner of your VSCode:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WYHgDuk---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/wsl-available.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WYHgDuk---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/wsl-available.png" width="300" alt="WSL Available"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on that green icon. You'll notice a dropdown menu appeared near the&lt;br&gt;
top of your VSCode. Click on &lt;code&gt;Remote-WSL: New Window&lt;/code&gt;. Now VSCode is asking&lt;br&gt;
for a folder to open. Browse to the &lt;em&gt;helloworld&lt;/em&gt; app we created before to&lt;br&gt;
test whether Rails was creating a server successfully. It should be something&lt;br&gt;
like &lt;code&gt;/home/USERNAME/helloworld/&lt;/code&gt;. Click OK. After a second, you should see&lt;br&gt;
a notification  at the bottom-right corner of VSCode stating that "Code&lt;br&gt;
Server" is being installed in WSL:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bVDU4lMV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/wsl-installing.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bVDU4lMV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/wsl-installing.png" width="750" alt="Code Server installing"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once this is finished, VSCode will open up a new window and your status&lt;br&gt;
at the bottom-left corner will change to &lt;code&gt;WSL: &amp;lt;DISTRO&amp;gt;&lt;/code&gt; like below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AYTYzIKB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/wsl-successful.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AYTYzIKB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/wsl-successful.png" width="300" alt="WSL connection successful"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you got all the way here, then congratulations! You can now successfully&lt;br&gt;
code from your Windows 10 machine using VSCode and see those changes&lt;br&gt;
reflected in real time in your server. Try it out by creating a hello-world&lt;br&gt;
view inside your helloworld app!&lt;/p&gt;
&lt;h3&gt;
  
  
  Test VSCode by Making Hello World View
&lt;/h3&gt;

&lt;p&gt;From your &lt;code&gt;helloworld&lt;/code&gt; app folder, go to &lt;code&gt;config &amp;gt; routes.rb&lt;/code&gt; and double&lt;br&gt;
click the file to open. Add the following line inside the &lt;code&gt;Rails.application.routes.draw do&lt;/code&gt; block:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt; &lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="s1"&gt;'application#hello'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8q9xSTk_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/helloworld-routes.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8q9xSTk_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/helloworld-routes.png" width="800" alt="Hello world route"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then go to &lt;code&gt;app &amp;gt; controllers &amp;gt; application_controller.rb&lt;/code&gt; and open the file.&lt;br&gt;
Inside the &lt;code&gt;ApplicationController&lt;/code&gt; class, add the following instance method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;hello&lt;/span&gt;
    &lt;span class="n"&gt;render&lt;/span&gt; &lt;span class="ss"&gt;html: &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;p&amp;gt;Hello worlddd &amp;amp;#x1F525;!!!&amp;lt;p&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;html_safe&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CqQFVz0z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/helloworld-controller.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CqQFVz0z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/helloworld-controller.png" width="800" alt="Hello world controller"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let's boot up the server again, and let's do it well. At the menu on the&lt;br&gt;
top, click on &lt;code&gt;Terminal &amp;gt; New Terminal&lt;/code&gt;, or better yet, press &lt;code&gt;CTRL+SHIFT+`&lt;/code&gt;&lt;br&gt;
(&lt;em&gt;" ` " is the key next to "1" in your keyboard&lt;/em&gt;). &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ogXpdvCk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/new-terminal.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ogXpdvCk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/new-terminal.png" width="800" alt="Open new terminal"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you open the terminal, &lt;strong&gt;make sure that the commands are being run from the helloworld folder.&lt;/strong&gt; This can be double-checked by looking at the&lt;br&gt;
terminal line:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g_l-beZh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/terminal-right.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g_l-beZh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/terminal-right.png" width="800" alt="Terminal in right folder"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If everything is going according to plan, then type the following in this&lt;br&gt;
new terminal:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rails server -b 0.0.0.0 -p 3000&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you have done everything well up to this point, visit &lt;a href="http://localhost:3000"&gt;http://localhost:3000&lt;/a&gt;&lt;br&gt;
and you will see this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AiNxa2uW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/helloworld-success.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AiNxa2uW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/serivas/wsl2_rails_setup/raw/master/img/helloworld-success.png" width="500" alt="Hello world success"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Don't forget to stop the server again, CTRL+C.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Congratulations, you are now up and running with VSCode + WSL2 + Ruby on Rails.&lt;br&gt;
Nothing is stopping you now.&lt;/p&gt;

</description>
      <category>wsl</category>
      <category>rails</category>
      <category>windows</category>
      <category>vscode</category>
    </item>
  </channel>
</rss>
