Spoiler. It all worked out of the box, really not satisfying if you’re a troubleshooter, really satisfying if you just want to get stuff done 🙂
Jump to the end for the short version.
Most of my development work is hybrid, I either develop on Windows (when at home) or Mac (on the go), but I mostly deploy on Linux.
I’ve been playing this game for over a decade, with good results. All except for my ruby projects. My ruby project suffer when I work on my main Windows machine because… well, it really doesn’t work as expected. Roughly said, ruby on Windows is mediocre.
That being said, this is my log for trying to setup my *nix-vim-vundle-rvm-ruby-sinatra-nginx environment on Windows 10 WSL.
Ok, first things first, this is WSL: https://msdn.microsoft.com/en-us/commandline/wsl/about
It works, I use it as a simple CLI daily on Windows now. Microsoft gets top kudos for this, I love it. Windows 10, updated, in Developer Mode is needed. That’s what you should be running anyway for your Windows box. After installing it, I started it up and made sure the underlying Ubuntu subsystem is up to date, also including vim and git:
sudo apt-get update sudo apt-get upgrade sudo apt-get install vim git
This is my basic editor setup, including the following vundle plugins
With that out of the way, let’s get some ruby on. For my rubies, both dev and prod, I use rvm (https://rvm.io/), a tool that I highly recommend. I always just use the install steps on the website, so:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 \curl -sSL https://get.rvm.io | bash -s stable
Surprisingly, that worked as a charm. Starting to get a good feeling about this.
Time to setup my ruby, this might get nasty, since it’s not gonna be a binary release for sure.
rvm install 2.4
And wow, turns out I was wrong and a binary was indeed available, working surprisingly out-of-the-box.
Let’s do a quick test, using a small pet project, just to make sure it can handle what I need. I fire up a new bash, go to a project directory and just do:
gem install bundler bundle install
Surprisingly, that worked, even for native extension based gems like sqlite, bcrypt and nokogiri seem to be installing. I could never get this to work properly on Windows! This is already a win.
The get s*it done side of me is exhilarating, the troubleshooter/hacker in me is demanding that a challenge to overcome be presented by this almost flawless process (up to this point).
And the first challenge appears, in the form of eventmachine:
And then, oooh, I’m an idiot, how did that slip:
sudo apt-get install build-essential postgresql-server-dev-9.5 libpq-dev
After that it went as smooth as it can possibly go
Now, for the front-end web server, we’re gonna setup nginx. I like my env to be as close as possible to the target environment.
sudo apt-get install nginx sudo service nginx start * Starting nginx nginx [fail]
And it failed.
2017/05/31 12:50:19 [emerg] 1520#1520: bind() to 0.0.0.0:80 failed (13: Permission denied)
Of course it did, it clashes with IIS on the same port, let’s quickly fix that by changing the nginx port.
sudo vim /etc/nginx/sites-enabled/default
Change “listen 80 defaults_server” to “listen 8080 default_server” and comment the IPv6 line. Also, if we’re there we can add “proxy_pass http://localhost:9292;” to the “location /” section for the reverse proxy.
Save, restart, it works.
Overall this was a fairly uneventful process with everything going smooth, frankly this was just a normal linux setup in all respects, which I guess is exactly what WSL is all about.
As a recap:
sudo apt-get update sudo apt-get upgrade sudo apt-get install vim git sudo apt-get install build-essential postgresql-server-dev-9.5 libpq-dev gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 \curl -sSL https://get.rvm.io | bash -s stable rvm install 2.4 gem install bundler bundle install rackup