I can build my rails application on my mac

On my Ubuntu machine when I bundle I get errors with a bunch of gems including nokogiri, version

Error installing nokogiri: ERROR: Failed to build gem native extensions

I try gem install nokogiri -v1.6.7.2 but I still get the error.

I am using rvm and ruby 2.3.0

2 Answers 2


If the above answer doesnt work try this

sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev

then install Nokogiri

gem install nokogiri

The key library here was libgmp-dev, installed with:

sudo apt-get install libgmp-dev

possibly due to my use of RVM to manage my ruby versions.

Once done, nokogiri and all the other failing gems were able to be installed (mostl easily just with bundle).

The other gems that had been failing were:

bcrypt-ruby 3.0.1
hitimes 1.2.3
ffi 1.9.10
eventmachine 1.0.7
geoip-c 0.8.1
mysql2 0.3.20

but after the nokogiri install they all installed with bundle

  • or you could just install the ruby-nokogiri package (with versions ranging from 1.5.0-1 in precise to in xenial - see packages.ubuntu.com/… ). bundling code that is available in a distro package is always a bad idea. instead, make a package of your code that depends on other packages....and if a particular ruby gem (or whatever) doesn't exist as a package, make a separate package of that rather than bundle it with your code.
    – cas
    Mar 29, 2016 at 3:08
  • BTW, ALL of the ruby gems you mention except for geoip-c are available pre-packaged for Ubuntu....and geoip-c's dependencies (minitest and rake) are both available as packages for ubuntu, so building a ruby-geoip-c package should be fairly easy.
    – cas
    Mar 29, 2016 at 3:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.