Obstacle Course Weekend

But not the physical kind.

I decided to play around with using Ruby for minimal testing setup, a current interest of mine – basically trying to reduce dependencies in a world where we want to spin up vm images such as docker in seconds all day long and the less to install the better for many reasons.

The obstacles I run into were not unusual to me at this point, but the ‘newbie person’ within me could clearly see that a newbie would be so lost with this stuff.

What happened:

1) I created a Gemfile to make sure my dependencies are installed.  Pretty minimal:

$ cat Gemfile
source 'https://rubygems.org'
gem 'minitest'
gem 'rspec-expectations'
gem 'selenium-webdriver'
Then I bundle to install them and got this:

$ bundle
Fetching gem metadata from https://rubygems.org/.........
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Installing ffi 1.9.25 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: /tmp/bundler20180805-19518-uwhdxgffi-1.9.25/gems/ffi-1.9.25/ext/ffi_c
/usr/bin/ruby2.3 -r ./siteconf20180805-19518-1pqqp5e.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /tmp/bundler20180805-19518-uwhdxgffi-1.9.25/gems/ffi-1.9.25 for inspection.
Results logged to /tmp/bundler20180805-19518-uwhdxgffi-1.9.25/extensions/x86_64-linux/2.3.0/ffi-1.9.25/gem_make.out
Using diff-lcs 1.3
An error occurred while installing ffi (1.9.25), and Bundler cannot continue.
Make sure that `gem install ffi -v '1.9.25'` succeeds before bundling.

Which is pretty cryptic !  At first it just seemed like some issue with ffi
What caught my eye though was the “mkmf.b” error.  That seemed odd.  Googling that showed that some folks needed ruby-dev so (on Ubuntu) I did

sudo apt-get install ruby-dev

and then bundle again and this time the webdriver dependency on ffi was able to be resolved.

I also noticed my sudo prompt kept saying

unable to resolve host my-machine-name

and I found that was because the /etc/hosts file had the old machine name before I changed it.  So I fixed that while I was at it too (required sudo vi /etc/hosts)

Not Rocket Science and resolved in 5 mins but this is the sort of thing that just trips so many folks up – including myself before I went through this sort of thing regularly and just got used to it.