Posted by Etienne van Delden on 6-4-2016
If you are developing Rails or Ruby applications, you probably have to install nokogiri, libv8 or therubyracer at some point.
Sadly enough, installing one of these gems on Mac OS X is always a hassle, for which I always keep forgetting the solution.
Here is my definite guide to installing nokogiri, libv8, therubyracer!
Assumptions
Before installing the actual gems, we will be using the following:
If you are only interested in installing the gem directly, you can use gem install GEM -- --OPTIONS instead of bundle config and bundle install.
nokogiri
Installation of nokogiri depends on xml2, so we’ll install that first.
1
brew install xml2
Now we can setup bundler to correctly install nokogiri.
1
2
bundle config build.nokogiri --use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2
bundle install
libv8
Installation of libv8 depends on (wait for it!) v8. OS X comes with a pre-installed v8.
1
2
bundle config build.libv8 --with-system-v8
bundle install
Note If you also need therubyracer, then see below
therubyracer
The therubyracer only works with libv8 that depends on an older version of v8, so we need to first install that older version.
1
2
brew tap homebrew/versions
brew install v8-315
Now we can setup bundler to correctly install therubyracer and libv8
1
2
3
4
bundle config build.therubyracer --with-v8-dir=/usr/local/opt/v8-315
bundle config build.libv8 --with-v8-dir=/usr/local/opt/v8-315
bundle install Happy coding!
This post is an amalgamation of three separate posts I wrote on eirvandelden.com