{"id":14955436,"url":"https://github.com/serivas/wsl2_rails_setup","last_synced_at":"2025-09-30T13:30:51.678Z","repository":{"id":132111543,"uuid":"252900149","full_name":"serivas/wsl2_rails_setup","owner":"serivas","description":"Tutorial to create a Rails local development environment for Windows 10 users, beginner friendly","archived":false,"fork":false,"pushed_at":"2020-04-05T00:40:53.000Z","size":1687,"stargazers_count":29,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-14T11:20:28.547Z","etag":null,"topics":["rails","rails6","vscode","windows-10","wsl","wsl-ubuntu","wsl2"],"latest_commit_sha":null,"homepage":null,"language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/serivas.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-04T03:35:12.000Z","updated_at":"2024-03-23T02:06:36.000Z","dependencies_parsed_at":"2023-11-30T06:35:16.057Z","dependency_job_id":null,"html_url":"https://github.com/serivas/wsl2_rails_setup","commit_stats":{"total_commits":1,"total_committers":1,"mean_commits":1.0,"dds":0.0,"last_synced_commit":"b8b6156d693468ef64b712127abffa1ca97f071a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serivas%2Fwsl2_rails_setup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serivas%2Fwsl2_rails_setup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serivas%2Fwsl2_rails_setup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serivas%2Fwsl2_rails_setup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serivas","download_url":"https://codeload.github.com/serivas/wsl2_rails_setup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234737845,"owners_count":18879180,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rails","rails6","vscode","windows-10","wsl","wsl-ubuntu","wsl2"],"created_at":"2024-09-24T13:11:09.313Z","updated_at":"2025-09-30T13:30:46.318Z","avatar_url":"https://github.com/serivas.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# How to setup Rails on Windows 10 for remote development\n\n## Introduction\n\nThis  repo is meant to help Windows 10 users set up their develpment environment\nto develop Ruby on Rails applications. This guide touches, among others, on:\n\n\u003col type=\"i\"\u003e\n \u003cli\u003e\u003ca href=#setting-up-wsl2-on-windows-10\u003e\n WSL 2 (Windows Subsystem for Linux)\u003c/a\u003e\u003c/li\u003e\n \u003cli\u003e\u003ca href=#setting-up-ruby-on-rails\u003eSetting up Ruby and Rails\u003c/a\u003e\u003c/li\u003e\n \u003cli\u003e\u003ca href=#setting-up-vscode-for-local-development\u003eSetting up VSCode for local development\u003c/a\u003e\u003c/li\u003e\n \u003cli\u003eSetting up VSCode for local/remote development using SSH\u003c/li\u003e\n\u003c/ol\u003e\n\n## Setting up WSL2 on Windows 10\n\nReference: [Install WSL 2 | Microsoft](https://docs.microsoft.com/en-us/windows/wsl/wsl2-install)\n\nThe first thing you want to do is make sure your Windows 10 version and\nbuild are compatible with WSL2 -- *As of April 3, 2020, version 1909,\nbuild 18363.720 is **not** compatible with WSL. This is the standard\nwidely distributed version at the moment*\n\nIf by the time you're reading this your windows version is lower than\nversion 2004, build 19041.153, then you will most likely have to\nget into the Windows Insider program to get Windows preview builds,\nmore information [on this page](https://insider.windows.com/en-us/).\n\n\u003eYou can check your windows version by typing `winver` on the start menu\n\n\u003cimg src=\"img/winver.png\" width=\"350\" alt=\"Windows version\"\u003e\n\n### Getting into the Insider Program\n\nIf you're not yet in the insider program, you can visit the\nfollowing link for very detailed instructions on how to\nenroll into Insider Program, and install WSL 2:\n\n\u003e [Official Microsoft's WSL2 Installation Instructions](https://docs.microsoft.com/en-us/windows/wsl/wsl2-install)\n\u003e\n\u003e [How to install Windows Subsystem for Linux 2 on Windows 10](https://pureinfotech.com/install-windows-subsystem-linux-2-windows-10/)\n\u003e\n\u003e *Note: These guides includes WSL2 installation too*\n\n If you want the short version, go to Settings \u003e Update\n\u0026 Security \u003e Windows Insider Program. There, make sure to get onto the\n**SLOW ring**. At the time this guide was first written, you don't need\n get into the Fast ring, so let's avoid unnecessary problems.\n\n\u003cimg src=\"img/insider1.png\" width=\"650\" alt=\"Enroll into insider preview\"\u003e\n\nAfter getting into the Slow ring, restart your PC if\nrequired. Then, check windows for updates on Settings \u003e\nUptade \u0026 Security \u003e Windows Update. **Once your Windows\nbuild is above build 18917, you can continue.**\n\n### Installing WSL2\n\nNow that you have the right OS build, you can enable WSL2\non your computer **manually** or **via Poweshell**:\n\n#### Powershell instructions\n\nOpen up Powershell as Admin by right clicking the Windows\nstart button and selecting \"Windows Powershell (Admin)\".\nThen, paste and run the following commands and restart your computer\nafter they are done running:\n\n```Powershell\ndism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart\n\ndism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart\n```\n\n#### Manual instructions\n\nGo to Windows' start menu, and type \"Turn Windows features\non or off\". If you click in the right item, you'll see the\nwindow below. Make sure to check \"Windows Subsystem for\nLinux\"\n\n\u003cimg src=\"img/winfeatures.png\" width=\"300\" alt=\"Turn on WSL feature\"\u003e\n\nYou'll probably be asked to restart your PC, please do so now.\nAfter enabling Windows Subsystem for Linux, then we have to\ninstall a Linux *distro* (short for distribution). Open up\nthe Windows Store app, and search for \"Linux\". You should\nsee something like the image below:\n\n\u003cimg src=\"img/winstore.png\" width=\"600\" alt=\"Linux subpage on Windows Store\"\u003e\n\nInstall \"Ubuntu\" from the linux subpage. It will take a few\nseconds. After it is installed, launch it. You will see a\n*terminal* window showing the following message:\n\n```bash\nInstalling, this may take a few minutes...\n```\n\nYou will be asked to create a default UNIX user account.\nMake sure it is a simple username (avoid mayus, symbols,\netc). Then type a password (*no characters will show\nwhile you type, so make sure you get it right!*) and\nconfirm it. If everything went according to plan, you\nshould see the following message:\n\n```none\nInstallation successful!\n\nTo run a command as administrator (user \"root\"), use\n\"sudo `\u003ccommand\u003e`\".\n\nSee \"man sudo_root\" for details.\n```\n\nCongratulations! You are now running a virtual Linux inside\nWindows 10. If anything didn't go as expected, Google the\nerror messages you get until everything is going as expected.\nAssuming you got the right version of Windows 10 running, if you\nmade a mistake while installing Ubuntu, you can always just uninstall\nfrom the Windows Store and try again. This will reset (almost)\neverything related to that Linux distro, so if you seriously mess up,\nyou can always reset.\n\n#### Making sure WSL version 2 is running\n\nIf you still have your Ubuntu *bash* terminal open, close it (*pro tip:\ntype `exit` instead of clicking the X arrow. Get used to the CLI -\nCommand Line Interface*). Open Powershell and type\n\n```Powershell\nwsl -l -v\n```\n\nYou should see something like this:\n\n\u003cimg src=\"img/wsllist.png\" width=\"600\" alt=\"Distros list\"\u003e\n\nIf your distro's version is NOT 2, then you definitely have to run the\ncommand below. If it is 2, you should run it anyways just in case:\n\n```Powershell\nwsl --set-version \u003cDistro\u003e 2\n```\n\nWhere `\u003cDistro\u003e` is your distro's name from the list (mine is \"Ubuntu\").\nYou will see online that some people have other names (like Ubuntu 18.04),\ndon't worry about that for now. If successful, you should see the following\nmessage:\n\n```none\nConversion in progress, this may take a few minutes...\n\nFor information on the key differences with WSL 2 please visit \u003chttps://aka.ms/wsl2\u003e\n```\n\nThen, run the following command so every next instance is WSL 2 too:\n\n```Powershell\nwsl --set-default-version 2\n```\n\nRun the `wsl -l -v` command again and make sure you got version 2 now. If\neverything went well, you have finished the WSL 2 setup part.\n\n## Setting up Ruby on Rails\n\nNow you have to update your Linux distro and set up Rails. For detailed and\nup-to-date instructions, you can visit [Rails Installation Tutorial](https://gorails.com/setup/windows/10#ruby);\nI recommend that you follow the steps outlined in this site and select all\nrecommended options and don't skip any steps! You will need everyhing done\nhere at some point or another. Most of the guide works, although some parts\nmay not work for you as time passes and different packages get updated. **For\ninstance, at this time, the installation instruction for PostgreSQL from\nthe tutorial above doesn't work** (I show how to do this below).\n\n\u003e **Tip:** when pasting lines of code into your Ubuntu bash terminal, CTRL+V\n\u003e won't work, but if you right-click the terminal it will paste the content\n\u003e from your clipboard.\n\n\u003e **Tip 2:** If this is your first time using the terminal, it's best if you\n\u003e paste commands 1 line at a time. Multi-line should work, but you may make\n\u003e mistakes as sometimes the last line doesn't run automatically.\n\n\u003cbr\u003e\n\u003cimg src=\"img/gorails1.png\" width=\"550\" alt=\"GoRails example\"\u003e\u003cbr\u003e\n\u0026nbsp;*GoRails tutorial example*\n\u003cbr\u003e\n\nAs you follow the steps above, make sure to read the return messages from\nthe terminal. If there's anything funky or you get an error message, stop\nand debug it! The order in which things are done makes a big difference.\n\nJust in case the guide above changes, I will show the instructions for Ruby\nversion 2.7.1 and Rails version 6.0.2.2 below, with some handy tips for\nbeginners.\n\n### Installing Ruby and Updating your Distro\n\nRuby is the backend language that powers Rails apps. This means that it\ncontrols the logic via scripts, just like Python or R. You can learn more\nabout this [here](https://www.ruby-lang.org/en/about/) and [here](https://ruby-lang.co/what-is-ruby/).\n\nFirst, let's get your distro upgraded! In Linux speech, \"update\" means\ngetting the latest version numbers, and \"upgrade\" means actually downloading\nand installing them. Run the following code in Ubuntu:\n\n```bash\nsudo apt update \u0026\u0026 sudo apt dist-upgrade \u0026\u0026 sudo apt-get autoremove \u0026\u0026 sudo\napt-get clean\n```\n\nIf you are asked to proceed, type \"Y\" and hit enter\n\n\u003cimg src=\"img/fstupdate.png\" width=\"500\" alt=\"First upgrade\"\u003e\n\nNow that your distro's libraries are up-to-date, let's proceed to install\nruby. Run the following 2 lines in your Ubuntu terminal:\n\n```bash\nsudo apt install curl\ncurl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -\ncurl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -\necho \"deb https://dl.yarnpkg.com/debian/ stable main\" | sudo tee /etc/apt/sources.list.d/yarn.list\n\nsudo apt-get update\n\nsudo 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\n```\n\nThat's a long code! If you are promped for your password, please input it\nand press enter. This is because we invoked sudo (*pro tip: sudo won't ask\nyou for a password for some time after inputting it successfully*).\n\nNow, let;s install Ruby using `rbenv`. Run the following lines in your\nbash terminal (same Ubuntu window):\n\n```bash\ncd\ngit clone https://github.com/rbenv/rbenv.git ~/.rbenv\necho 'export PATH=\"$HOME/.rbenv/bin:$PATH\"' \u003e\u003e ~/.bashrc\necho 'eval \"$(rbenv init -)\"' \u003e\u003e ~/.bashrc\nexec $SHELL\n\ngit clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build\necho 'export PATH=\"$HOME/.rbenv/plugins/ruby-build/bin:$PATH\"' \u003e\u003e ~/.bashrc\nexec $SHELL\n\nrbenv install 2.7.1\nrbenv global 2.7.1\nruby -v\n```\n\nNow let's install bundler, which is an impotant gem (ruby libary):\n\n```bash\ngem install bundler\nrbenv rehash\n```\n\n### Configuring Git\n\nIf you don't already have a GitHub account, [create one now](https://github.com/join?source=header-home).\nThis will come very handy in the future, and some things we do here (like\ncreating SSH keys) will be useful outside of Git and Github, so no skipping.\n\nAfter creating your Github account (or if you already had one), paste the\nfollowing commands in your terminal, replaceing the items in CAPS with your\nname (use your UNIX username for simplicity) and github email:\n\n```bash\ngit config --global color.ui true\ngit config --global user.name \"YOUR NAME\"\ngit config --global user.email \"YOUR@EMAIL.com\"\nssh-keygen -t rsa -b 4096 -C \"YOUR@EMAIL.com\"\n```\n\nWhen prompted for a location, just press enter. Same for password, no need\nto add a password to this for now. If successful, this is a sample output:\n\n```none\nGenerating public/private rsa key pair.\nEnter file in which to save the key (/Users/USERNAME/.ssh/id_rsa):\nEnter passphrase (empty for no passphrase):\nEnter same passphrase again:\nYour identification has been saved in /Users/USERNAME/.ssh/id_rsa.\nYour public key has been saved in /Users/USERNAME/.ssh/id_rsa.pub.\nThe key fingerprint is:\n80:5f:25:7c:f4:90:aa:e1:f4:a0:01:43:4e:e8:bc:f5 vivek@desktop01\nThe key's randomart image is:\n+--[ RSA 2048]----+\n| oo    ...+.     |\n|.oo  .  .ooo     |\n|o .o. . .o  .    |\n| o ...+o.        |\n|  o .=.=S        |\n| .  .Eo .        |\n|                 |\n|                 |\n|                 |\n+-----------------+\n```\n\nWe just generated fancy, industrial-grade security keys. This is much more\nconvenient and secure than using passwords (even though you would never\nre-use a password, rigt?). So we'll paste the encrypted PUBLIC key into\nGithub, which will accept our connections in the future without the need\nof a password. Get your public key by running the following command:\n\n```bash\ncat ~/.ssh/id_rsa.pub\n```\n\nThis will output the contents of the \"id_rsa.pub\" file, which holds your\nSSH public key. Once you get that output, you can select it with your\nmouse and right-click it to copy it (remember, CTRL+C doesn't copy things\nin the Ubuntu bash terminal).\n\n\u003e Note: the ~ variable is the same as typing \\$HOME, which is a variable as\n\u003e indicated by the preceding dollar sign (\\$). This is just a shortcut to\n\u003e indicate your user's home folder, very similar to your user folder in\n\u003e Windows 10.\n\nThe command's output should look something like this:\n\n```none\nssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSU\nGPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3\nPbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XA\nt3FaoJoAsncM1Q9x5+3V0Ww68/eIFmb1zuUFljQJKprrX88XypNDvjYNby6vw/Pb0rwert/En\nmZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbx\nNrRFi9wrf+M7Q== USER@HOSTNAME\n```\n\nNow, let's head to [Github](https://github.com/settings/keys) and paste that\nSSH key [in here](https://github.com/settings/ssh/new). Remember to give this\nkey a name so you remember it's your WSL 2 connecting to Github. Let's\ndouble-check that everything worked out, run the following command:\n\n```bash\nssh -T git@github.com`\n```\n\nYou should see something like this:\n\n```none\nHi USERNAME! You've successfully authenticated, but GitHub does not provide shell access.\n```\n\nGreat! So now we have a) WSL 2 set up, b) an Ubuntu distro installed and\nupdated, c) Ruby installed, and d) an SSH key pair created and successfully\nconnected to Github. We're almost there.\n\n### Installing Rails\n\nRun the following commands in your bash terminal:\n\n```bash\ncurl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -\ncurl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -\necho \"deb https://dl.yarnpkg.com/debian/ stable main\" | sudo tee /etc/apt/sources.list.d/yarn.list\n\nsudo apt update\nsudo apt-get install -y nodejs yarn\n```\n\nThis may take a few minutes as you're installing NodeJS and Yarn, two very\nimportant packages.\n\n\u003e *Note: you may have noticed that whenever we run the\n\u003e `apt update` or `apt-get install` commands we get more packages, and\n\u003e whenever we run `gem install` command we get more \"gems\" (ruby libraries)*\n\nAnd now we finally install Rails (this may take a few minutes too):\n\n```bash\ngem install rails -v 6.0.2.2\nrbenv rehash\n```\n\nLet's test it out by running `rails -v`, you should get:\n\n```bash\nrails -v\nRails 6.0.2.2\n```\n\nIf you get anything different, start debugging/Googling.\n\n### Installing and Configuring PostgreSQL\n\nYou can install PostgreSQL in Windows or directly in the WSL. It is easier\nto install it in Windows, but I prefer separating my development environment\nfrom my personal user space, so I'll show how to install it in your WSL.\n\nAs of April 3, 2020, installing PostgreSQL-11 isn't trivial. First, let's\ngo to [Postgre's website](https://www.postgresql.org/download/linux/ubuntu/).\nChoose your Ubuntu apt repository (most likely Bionic 18.04) and run the\nfollowing commands from your bash terminal:\n\n```bash\nsudo vim /etc/apt/sources.list.d/pgdg.list\n```\n\nVim is the terminal's text editor. **Don't try typing things yet!** Vim\ndoesn't start in \"insert mode\" which is the mode that lets you type stuff,\ninstaed it starts in the mode that accepts commands. So first push the \"i\"\nkey in your keyboard. This will take vim into \"insert mode\" like below:\n\n\u003cimg src=\"img/vimins.png\" width=\"500\" alt=\"Vim insert mode\"\u003e\u003cbr\u003e\n\u0026nbsp;*Vim in insert mode -\u003e text editing enabled*\n\nNow that we can insert stuff, paste the following line into the\ndocument (remember to right-click)L\n\n```vim\ndeb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main\n```\n\n\u003cimg src=\"img/vimpaste.png\" width=\"500\" alt=\"Pasted code\"\u003e\n\nAfter pasting that line, we have to save and exit. To do this, first\nexit INSERT mode by pressing your ESC key. You'll notice that the\n-- INSERT -- message disappeared from the bottom left corter of\nvim's screen. Now, type `:w` and press enter. This will ask vim\nto **write** changes into the file. Then, type `:q` which will ask\nvim to exit (*Note: you can also do `:wq` to do both at the same time*).\n\nWe just added the information required for bash to successfully get the\nlatest version of PostgreSQL. So now we'll get it! Run the following\ncommand in bash:\n\n```bash\nwget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -\n\nsudo apt-get update\n```\n\nWe got the update info now, let's install:\n\n```bash\nsudo apt-get install postgresql-11\n\nsudo apt install libpq-dev\n```\n\nNow that PostgreSQL is installed, let's set up a user. Run the code below\nreplacing `USERNAME` for your UNIX user for simplicity:\n\n```bash\nsudo -u postgres createuser USERNAME -s\n```\n\nAnd now we're done with PostgreSQL! All that's left is to test the server:\n\n### Testing Rails server\n\nTo see whether things are working, lets boot up a server. Run the following\nlines of code in your terminal:\n\n```bash\ncd\nrails new helloworldapp\ncd helloworldapp\nrails server -b 0.0.0.0 -p 3000\n```\n\n\u003cimg src=\"img/pumaboot.png\" width=\"550\" alt=\"Puma server booted\"\u003e\u003cbr\u003e\n\u0026nbsp;*Puma server booted successfully*\n\nNow, if you were able to boot up Puma successfully, you\nshould be able to open up Chrome or any other browser and\nenter `http://localhost:3000` in the address bar. If you\ndid everything well, you should see the following page:\n\n\u003cimg src=\"img/yayrails.png\" width=\"550\" alt=\"Rails successful\"\u003e\n\nRejoice! The hard part is over. **Now, close your server by going back to the\nterminal and pressing CTRL+C**\n\n## Setting up VSCode for Local Development\n\nIt's great that you have a server up and running, but you will most likely\nwant to have real-time access to the code and assets in the server. The files\nthat live in your Linux subsystem don't like comingling with your Windows\nfiles (they are completely separate Operating Systems after all). *This means\nthat you can't really edit those files DIRECTLY from Windows*. If we left\nthings as they are now, you would have to make some code, upload it to\nGithub, and then download it using your Ubuntu terminal. This would be\ncumbersome to say the least.\n\nFret not! Since your WSL lives inside Windows, you CAN edit the files using\nWindows, but *not directly*. This means that you will be able to code and\ninstantly see the changes you made in the same computer.\n\nIf this sounds a bit too technical, **just follow these steps so you can\nuse VSCode inside your new Linux environment.**\n\n### Download and Install VSCode\n\nIn case you don't already have VSCode, then [please download and install it\nnow](https://code.visualstudio.com/download) (*download the Windows 64 bit\nversion unless you know you have a different Operating System*). You may be\nthinking about downloading the Ubuntu version, but don't. WSL 2 is *kind of*\nLinux, but not full fledged, VSCode needs to run from a fully functional\nOperating System like the Windows 10 you're running now.\n\n\u003e Make sure to leave the \"Add to PATH\" checkbox **TICKED**\n\nSome resources in case something goes wrong:\n\n[Official \"Developing in WSL\" guide](https://code.visualstudio.com/docs/remote/wsl)\u003cbr\u003e\n[Remote development in WSL guided tutorial](https://code.visualstudio.com/remote-tutorials/wsl/getting-started)\u003cbr\u003e\n[Remote-WSL Extension site](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl)\u003cbr\u003e\n[Full guide from Microsoft](https://devblogs.microsoft.com/commandline/an-in-depth-tutorial-on-linux-development-on-windows-with-wsl-and-visual-studio-code/)\u003cbr\u003e\n\n### Install Remote Development Extensions\n\nAfter installing, open VSCode. It will most likely offer you to install a\n\"Remote-WSL\" extension. Don't do it for now. Go to extensions on the left\n(or hit CTRL+SHIFT+X) and paste this into the search bar:\n\n```none\nRemote Development\n```\n\nYou should see something like the picture below but with\nthe option to install available (I already have it installed\nso it doesn't show up):\n\n\u003cimg src=\"img/remoteext.png\" width=\"350\" alt=\"Remote Extension\"\u003e\n\nInstall this one. If you installed it successfully, you should see the little\nconnection icon in the bottom-left corner of your VSCode:\n\n\u003cimg src=\"img/wsl-available.png\" width=\"200\" alt=\"WSL Available\"\u003e\n\nClick on that green icon. You'll notice a dropdown menu appeared near the\ntop of your VSCode. Click on `Remote-WSL: New Window`. Now VSCode is asking\nfor a folder to open. Browse to the *helloworld* app we created before to\ntest whether Rails was creating a server successfully. It should be something\nlike `/home/USERNAME/helloworld/`. Click OK. After a second, you should see\na notification  at the bottom-right corner of VSCode stating that \"Code\nServer\" is being installed in WSL:\n\n\u003cimg src=\"img/wsl-installing.png\" width=\"500\" alt=\"Code Server installing\"\u003e\n\nOnce this is finished, VSCode will open up a new window and your status\nat the bottom-left corner will change to `WSL: \u003cDISTRO\u003e` like below:\n\n\u003cimg src=\"img/wsl-successful.png\" width=\"250\" alt=\"WSL connection successful\"\u003e\n\nIf you got all the way here, then congratulations! You can now successfully\ncode from your Windows 10 machine using VSCode and see those changes\nreflected in real time in your server. Try it out by creating a hello-world\nview inside your helloworld app!\n\n### Test VSCode by Making Hello World View\n\nFrom your `helloworld` app folder, go to `config \u003e routes.rb` and double\nclick the file to open. Add the following line inside the `Rails.application.routes.draw do` block:\n\n```ruby\n root 'application#hello'\n```\n\n\u003cimg src=\"img/helloworld-routes.png\" width=\"800\" alt=\"Hello world route\"\u003e\n\nThen go to `app \u003e controllers \u003e application_controller.rb` and open the file.\nInside the `ApplicationController` class, add the following instance method:\n\n```ruby\n  def hello\n    render html: (\"\u003cp\u003eHello worlddd \u0026#x1F525;!!!\u003cp\u003e\").html_safe\n  end\n```\n\n\u003cbr\u003e\n\n\u003cimg src=\"img/helloworld-controller.png\" width=\"800\" alt=\"Hello world controller\"\u003e\n\nNow let's boot up the server again, and let's do it well. At the menu on the\ntop, click on `Terminal \u003e New Terminal`, or better yet, press ``CTRL+SHIFT+` ``\n(*\" \\` \" is the key next to \"1\" in your keyboard*). \n\n\u003cimg src=\"img/new-terminal.png\" width=\"800\" alt=\"Open new terminal\"\u003e\n\nOnce you open the terminal, **make sure that the commands are being run from the helloworld folder.** This can be double-checked by looking at the\nterminal line:\n\n\u003cimg src=\"img/terminal-right.png\" width=\"800\" alt=\"Terminal in right folder\"\u003e\n\nIf everything is going according to plan, then type the following in this\nnew terminal:\n\n```bash\nrails server -b 0.0.0.0 -p 3000\n```\n\nIf you have done everything well up to this point, visit \u003chttp://localhost:3000\u003e\nand you will see this:\n\n\u003cimg src=\"img/helloworld-success.png\" width=\"500\" alt=\"Hello world success\"\u003e\n\n\u003e **Don't forget to stop the server again, CTRL+C.**\n\nCongratulations, you are now up and running with VSCode + WSL2 + Ruby on Rails.\nNothing is stopping you now.\n\n\u003c/br\u003e\u003c/br\u003e\n\nTODO\n\n* Windows terminal\n* Setting up VSCode via WSL 2 connection\n* Forwarding ports, making website discoverable in local\nnetwork on startup (NIC bridge)\n* Allowing connection via hostname instead of IP\n* Advanced: Setting up VSCode via SSH, automating SSH Daemon\non startup\n\n\n\n\n\u003c!---\npowershell for linux:\nhttps://linuxhint.com/install_powershell_ubuntu/\nwget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb\n\nSSH:\nhttps://code.visualstudio.com/docs/remote/ssh\nhttps://code.visualstudio.com/docs/remote/troubleshooting#_installing-a-supported-ssh-client\nhttps://gist.github.com/dentechy/de2be62b55cfd234681921d5a8b6be11\n\nPorts:\nhttps://github.com/microsoft/WSL/issues/4150#issuecomment-504209723\n\n---\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserivas%2Fwsl2_rails_setup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserivas%2Fwsl2_rails_setup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserivas%2Fwsl2_rails_setup/lists"}