How to develop Ruby on Rails with Windows 10’s Linux Subsystem


It has been quit sometimes that Windows developer don’t have an easy way to create Rails application. The most common way is to install Linux Virtual Machine or Docker. In a latest update of Windows 10, It has a new feature called “Windows Subsystem for Linux”. Underneath of this subsystem is Ubuntu Linux. In this article, I will guide you to create the Rails application based on Windows Subsystem for Linux.

Prepare a System

    1. Making sure your Windows Version is build 1607+, by Open Settings > System > About

    2. Enable Windows Subsystem for Linux by Open Settings > search for Turn Windows features on or off then check Windows Sussystem for Linux (Beta)


    3. Turn On Developer Mode, by Open Settings > Update & Securities > For developers

 

  1. Open Bash command by search from Task Bar. As the first time, It will ask you to install Linux Subsystem. You can press Y to continue. After that you can give the user name of your Ubuntu. In this article we use root


Install Ruby On Rails

After that you can start to install Ubuntu Libraries and Ruby On Rails just like you work under Ubuntu Linux

  1. Install Ruby and Libraries via apt-get
    apt-get update 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 libffi-dev nodejs ruby ruby-dev 
  2. Install Rails with RubyGem
    gem install rails 

Create your first Rails App on Windows

Everything will be the same as regular Rails development under Unix system from now on

  1. Create Rails App
    rails new e-shop 
  2. Run database migration and start rails servers
    cd e-shop
    rails db:migration
    rails server 

Congratulation!. You now can see that Windows subsystem Linux allow us to develop a whole Ruby On Rails ecosystem in Windows 10. Please feels free to drop a question or comment

 

References