# Installing RoR on WSL

Installation instructions for wsl: https://docs.microsoft.com/en-us/windows/wsl/install-win10

Assuming wsl is already installed and the terminal is up and running.
First install some dependecies
```shell
sudo apt-get update
sudo apt-get install git-core curl 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
```
Then install rbenv, it is preferred over rvm because the later has some security concerns regarding some scripts it runs on your machine.
```shell
cd

git clone https://github.com/rbenv/rbenv.git ~/.rbenv

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc

echo 'eval "$(rbenv init -)"' >> ~/.bashrc

exec $SHELL

git 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
```
Then use rbenv to install your preferred version of ruby(You can install multiple based on the version needed for your projects)
```shell
rbenv install 2.7.0

rbenv global 2.7.0 #Sets the default version to use

ruby -v #Show current ruby version
```
Install bundler:
```shell
gem install bundler

rbenv rehash
```
Rails requires a lot of dependencies so you should install NodeJs and yarn
```shell
curl -sL https://deb.nodesource.com/setup_12.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 update

sudo apt-get install -y nodejs yarn
```
Then install your preferred version of rails
```shell
gem install rails -v 6.0.3
```
Run rbenv rehash so rails executable becomes available
```shell
rbenv rehash


rails -v
```
