Some problems I encountered before when trying to setup
capybara. (Rails 4.1.5).
Below is the error message you get when you do
bundle install after adding
gem capybara to your
Using mini_portile 0.6.0 Building nokogiri using packaged libraries. Gem::Ext::BuildError: ERROR: Failed to build gem native extension. /Users/roy/.rvm/rubies/ruby-2.1.2/bin/ruby -r ./siteconf20140819-26712-14kvhdl.rb extconf.rb Building nokogiri using packaged libraries. ----- libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies. ----- *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.
Solution: Install Nokogiri
I'm using home brew so these steps worked for me:
brew install libxml2 libxslt brew link libxml2 libxslt --force
I had to use
--force which is not stated in the official installation guide.
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz tar xvfz libiconv-1.13.1.tar.gz cd libiconv-1.13.1 ./configure --prefix=/usr/local/Cellar/libiconv/1.13.1 make sudo make install
gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
Yes, the directory for
libxslt points to an empty directory because the installed version is actually 2.9.1 and 1.1.28 respectively. But it installs fine, so we'll move on.
You'll also notice the message:
However, note that nokogiri does not necessarily support all versions of libxml2. For example, libxml2-2.9.0 and higher are currently known to be broken and thus unsupported by nokogiri, due to compatibility problems and XPath optimization bugs.
Nokogiri seems to be installed properly so we'll move on.
Nokogiri is installed, you should be able to do
bundle install now.
You might need to add
config.include Capybara::DSL to
If you have any idea to install
Nokogiri without any errors, please do drop a note.
I have not tested this in depth, but just noting down the steps first.
- Dependancies hurt -