No BS freelance development

O Ruby, Where Art Thou?

December 11, 2016

I needed a blog, didn't want to mess around with Wordpress templates, I wished for something more than Medium and I thought Javascript is bullshit (not anymore, that was sheer ignorance on my part), so Ruby it was.

Ruby's happy-go-lucky style was a breath of fresh air after the Swift's type nazi attitude.


Trying to set up a real-life Ruby app and environment is a command line nightmare which only ends when the dependency gods have finally had enough of toying with your soul.


I heard Rails was hot shit, so naturally the first step after learning the language was to try and integrate Rails. Only, Rails is not something you integrate. Because it's not a library. Which I totally thought it was.

Instead, Rails is part a kind of wrapper around the language, part project management software, part language extension, part an abstraction over the standard library, part unicorn tears. It's all very confusing.

Rails is also a dependency.

Any self-respecting tutorial on the subject will tell you to just gem install rails.

Sure. What the hell is gem again? Turns out it's a command that calls rubygems. So what is that? A bit of googling will tell you it's a dependency manager for Ruby. Apparently it comes with macOS. Huh. Good to know.

Wardrobe change

Alright, so gem install rails gives the following error:

ERROR: Could not find a valid gem 'rails' (>= 0), here is why: Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)

Apparently it has something to do with outdated certificate files. Whatever. You need something called the RVM - Ruby Version Manager.

At first, needing a third party version manager of the language to fix a dependency manager was laughable so I wasted one more hour before giving RVM a try.

Curiously, it's written that "recent versions of RVM include a utility to diagnose and resolve errors caused by outdated certificates" (as of December 2013). Whatever the hell anyone was using before that to resolve this issue is beyond me.

Now, here are the steps to installing RVM:

$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

$ \curl -sSL https://get.rvm.io | bash -s stable --ruby

While we are at it, let's update Ruby, with a piped command after curling RVM.

gpg --keyserver ... fails because my system has no knowledge of whatever a "gpg" is:

Obviously we need to download it. We do that with the following command:

$ brew install gnupg gnupg2

There are a few things to note here:

  1. The brew command refers to Homebrew which is a dependency manager for macOS. At this point we are using a dependency manager to get a dependency (gnupg gnupg2) of a version manager to fix another dependency manager.
  2. Also, brew install gnupg gnupg2 fails with the following error:

/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- mach (LoadError)


Obviously, Homebrew is broken. The El Cap update broke it when they decided that usr/local/bin is the one true place to put your shit and anything else is extra heretical.

So to fix Homebrew, we need to:

$ sudo chown -R $(whoami):admin /usr/local

It's important to note here, that I have no idea what I'm doing anymore.

Also, now you can install RVM to fix rubygems to install Rails.


It seems you cannot spell Ruby without Rails but then I'd rather have bad spelling than generate a bloated mess for a "Hello World" app. Or any other app for that matter.

But I guess it's ok, since Rails is "opinionated". It's apparently also ok for a dependency to have a fuckmillion dependencies of its own.


After removing Rails and decontaminating my machine with sulfuric acid, I've stumbled upon Sinatra which is Rails, but without the ugly. It's actually just a DSL on top of Ruby.

It doesn't generate an operating system worth of garbage, has much fewer dependencies and is a joy to use. Yay!

We need to install Sinatra though...

Luckily most of the stuff we need to deal with has been dealt with, so gem install sinatra is done with relative ease... in 688 seconds.

$ Done installing documentation for rack, rack-protection, tilt, sinatra after 688 seconds


All that's left is to require 'sinatra' in our ruby file and we are good to go.

require': cannot load such file -- sinatra (LoadError)

Wait, what?

After some frantic googling, it turns out RVM stores gems by Ruby version and also, when we update ruby (as I did as part of the RVM installation), it doesn't actually update Ruby, it just install the new version so you have multiple rubies on your system. The new one does not take precedence. The way to do that is to remove the old Ruby.

rvm remove 2.2

This did the trick, but now that 2.3 became the default, sinatra needs installing again.

gem install sinatra