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
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.
- Update to Windows Insider Fast Track version >14316
- Settings > Updates & Security > For developers > Check “Developer Mode”
- Open “Windows Features” (from Cortana) > Check “Windows Subsystem for Linux (Beta)”. Restart.
- Open Bash.exe for the first time to install Ubuntu.
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
$ 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
For Node v4:
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - sudo apt-get install -y nodejs
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
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
gem install nokogiri -- --use-system-libraries
Hopefully this saves you some
gem install failure and heartache.
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:
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.