extconf failed, exit code 1 error when installing [Ruby on Rails] 5 on OS X Yosemite 10.10.5

Solution 1:

http://www.nokogiri.org/tutorials/installing_nokogiri.html says they recommend installing with included libraries, not installing with system libraries.

So I tried (on Ubuntu) following the instruction there, and it worked

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