Web development moves fast. This post is old. A new step-by-step guide to setting up a Windows 10 web developer environment is now available.

After getting Jekyll on Bash on Ubuntu on Windows1 up and running I said my next challenge was getting Ruby on Rails and I have some good news:

Ruby on Rails welcome screen reporting Linux as the OS

You’ll see Linux is being reported as the Operating System. That’s because Bash on Ubuntu on Windows is Linux, just with a few weird compat bugs (but doesn’t normal Linux also have those?).

Eventually, something like a standard “Install Rails on Ubuntu” tutorial should work on Bash on Ubuntu on Windows, but at the time of writing neither rbenv nor rvm work. Ideally you don’t sudo gem install, but for this environment everyone who tested needed root permissions. So here we go…

Install the Linux Subsystem

First, you’ll need the Linux subsystem. If you’ve already got it installed, you can skip this.

  1. Update to Windows Insider Fast Track version >14316
  2. Settings > Updates & Security > For developers > Check “Developer Mode”
  3. Open “Windows Features” (from Cortana) > Check “Windows Subsystem for Linux (Beta)”. Restart.
  4. Open Bash.exe for the first time to install Ubuntu.

Install Ruby

You’ll need to install Ruby 2.3. If you’ve already tried the Jekyll install or done this, you can skip this section.

First, let’s make sure you’re root to update and install make and gcc compiler:

$ sudo -s
$ apt update
$ apt install make gcc

You may get E: Sub-process /usr/bin/dpkg returned an error code (1) errors, while alarming, they don’t prohibit progress. Next, add the Brightbox-maintained Ruby libs (still not sure if this is the best option):

$ apt-add-repository ppa:brightbox/ruby-ng
$ apt update
$ apt install ruby2.3 ruby2.3-dev ruby-switch

Verify Ruby is installed and/or switch if necessary:

$ ruby -v
$ ruby-switch --set ruby2.3

Install Rails Dependencies

Rails has a few dependencies you’ll need to install. The most significant of which is Node ( errrrt… record scratch sound effects ) that is used by the Asset Pipeline to uglify JavaScript. If you already have Node 4+, skip this step.

For Node v4:

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs

For SQLite3:

apt install sqlite3 libsqlite3-dev

For Nokogiri, Rails’ XML parser, you’ll need some XML libs:

apt install zlibc zlib1g-dev libxml2 libxml2-dev libxslt1.1 libxslt1-dev

At the time of writing, there’s a Nokogiri bug in 1.6.8 where iconv tries to install libxml2-2.9.4 and fails. This is happening on Mac and Windows (confirmed). You’ll need to install Nokogiri and force it to use the working version of libxml (2.9.1) we just installed with apt:

gem install nokogiri -- --use-system-libraries

Hopefully this saves you some gem install failure and heartache.

Install Rails

From here it’s a pretty straight forward Rails app:

$ gem install bundler
$ gem install rails --pre
$ rails new testapp
$ cd testapp
$ rails server

Rails 5.0.0.beta3 should now boot up on http://localhost:3000. From a cold start on a scaffolded posts#index with a title and a body, here’s the results:

Completed Views ActiveRecord
Powershell 725ms 696.2ms 1.5ms
Bash 415ms 383.3ms 2.4ms

A 300ms improvement (nearly twice as fast) is wonderful and brings me closer to production server responses.

The Year of Linux on the Desktop

Let me know if you have problems or I messed up. I’m still learning the ins-and-outs of a third operating system. I used to consider myself very Linux proficient, but not anymore faced with a naked install.

I’m very much a “Best Practices” guy and would like to be following the most common convention with the minimal amount of effort. For better or for worse, abstractions like Homebrew numbed me to what was happening behind the scenes. Taking that convenience away has taught me a lot.

Next step is Postgres, Image Processing with Paperclip, Authentication with Devise, and trying to push the limits a bit further.

Thanks to Schneems, Chris, James, and Tom for tech checking this post.

  1. UPDATE: Jekyll on Bash on Ubuntu on Windows is blocked by a libinotify file watching bug. This affects any file watching task (like Sass) that of Ruby and Node workflows depend on. If you want to do modern web development on Bash on Ubuntu on Windows, please vote it up in User Voice.