DEV Community

Cover image for Installing RoR on WSL
Oluwafemi Lawal
Oluwafemi Lawal

Posted on

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 dependencies

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
Enter fullscreen mode Exit fullscreen mode

Then install rbenv, it is preferred over rvm because the later has some security concerns regarding some scripts it runs on your machine.

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
Enter fullscreen mode Exit fullscreen mode

Then use rbenv to install your preferred version of ruby(You can install multiple based on the version needed for your projects)

rbenv install 2.7.0

rbenv global 2.7.0 #Sets the default version to use

ruby -v #Show current ruby version
Enter fullscreen mode Exit fullscreen mode

Install bundler:

gem install bundler

rbenv rehash
Enter fullscreen mode Exit fullscreen mode

Rails requires a lot of dependencies so you should install NodeJs and yarn

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
Enter fullscreen mode Exit fullscreen mode

Then install your preferred version of rails

gem install rails -v 6.0.3
Enter fullscreen mode Exit fullscreen mode

Run rbenv rehash so rails executable becomes available

rbenv rehash


rails -v
Enter fullscreen mode Exit fullscreen mode

Top comments (0)