Setting Up Rails on Windows with WSL2
Introduction
This guide is for people who wish to use Ruby on Rails natively on their Windows machine.
Windows Subsystem for Linux Version 2 (WSL2) is a compatibility layer for Windows 10 and 11 which allows Linux applications/binaries to be run at near-native speeds within the Windows environment.
Copyright By PowCoder代写 加微信 powcoder
These instructions have been tested with Windows 10 but they should also work with subsequent versions.
Requirements
WSL2 requires Windows Home or Professional; it does not support Windows in S mode. If you are using Windows 10, ensure you have installed any updates because WSL2 requires version 2004 or higher.
Installing WSL2
1. Open ¡°Windows PowerShell¡± as an administrator. This can be done by searching for ¡°PowerShell¡± in the Windows search, right-clicking, and choosing the ¡°Run as administrator¡± option.
2. Run the following command in PowerShell to enable the Windows Subsystem for Linux feature:
dism.exe /online /enable-feature
/featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Please note: The command above is a single line. Take care if copying and pasting.
3. Run the following command in PowerShell to enable the Virtual Machine Platform
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform
/all /norestart
Please note: The command above is a single line. Take care if copying and pasting.
4. Now restart your computer.
5. Run the following command in PowerShell to set the default WSL version to 2:
wsl –set-default-version 2
6. If you have previously installed WSL1, after running the above command you will be asked to update the kernel component. Follow the link provided and run the package to update to WSL2 and then run the above command again. Please note that if you have previously used WSL1 you will need to remove any existing Ubuntu installations before continuing.
7. Open the Microsoft Store, search for ¡°Ubuntu¡±, and install ¡°Ubuntu 20.04 LTS¡±.
8. Find the newly installed ¡°Ubuntu 20.04 LTS¡± app and run it. This should open a new terminal within the WSL2 installation. If the setup does not complete after a few minutes, click on the terminal and press the enter key.
9. Set up your username, password and other settings as prompted by the terminal.
Installing Visual Studio Code (VSCode)
The recommended way of developing applications within a WSL2 instance is to use VSCode. With the use of a plugin provided by Microsoft, you can set up a Linux-based coding environment within WSL2 whilst working within Windows.
1. Start VSCode. If you have not already installed it you can download it here:
https://code.visualstudio.com
2. Install the ¡°Remote Development¡± extension pack by pressing CTRL+P, typing the following command and pressing enter:
ext install ms-vscode-remote.vscode-remote-extensionpack
3. Press F1 to open the ¡°Command Palette¡± which allows you to manually run commands within VSCode. Search for ¡°Remote-WSL: SL Window¡± and click on it or press enter. This will open a new VSCode window connected to WSL2.
4. To verify the connection to WSL2, open a new terminal by clicking ¡°Terminal > ¡± in the top menu of VSCode and enter the following command:
lsb_release -a
5. Within the output you should see ¡°Description: Ubuntu 20.04.3 LTS¡±.
Setting Up Rails
You should now continue with the instructions in the guide for ¡°Setting Up Rails on Ubuntu¡±.
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com