Installing gems with native extensions on TravisCI

I was mucking around with TravisCI recently. And when I was setting up a Rails project with travis. I hit a wall trying to get a ruby gem (https://github.com/da4nik/geoip2) with a native extention (https://github.com/maxmind/libmaxminddb) to get to install on travis.

Thanks to GeoIP2-python (https://github.com/maxmind/GeoIP2-python/blob/master/.travis.yml)'s travis.yml I figured out how to solve the issue.

It's pretty straight forward really. Travis builds your project on a Ubuntu machine on cloud. So you'd install anything on it just as you would on a Ubuntu box.

As for the library above, you can add the build steps in before_install (in your travis.yml).

before_install:  
  - git submodule update --init --recursive
  - git clone --recursive git://github.com/maxmind/libmaxminddb
  - cd libmaxminddb
  - ./bootstrap
  - ./configure
  - make
  - sudo make install
  - sudo ldconfig
  - cd ..

It's important not to omit the last command (cd ..). If not all your other build steps would run inside the libmaxminddb folder (remmber cd libmaxminddb).

Cheers!