I am trying to install Nokogiri on my computer (Mountain Lion) for use with rspec and capybara, but for the life of me I cannot make it work normally.
From what I can tell, the problem is with nokogiri using the wrong version of libxml2. I still tried to uninstall and reinstall libxml2 using Homebrew (make sure it is the latest), uninstall and reinstall nokogiri using the package, and specify the exact path to the libxml2 files that Homebrew installed when installing nokogiri gem. My latest installation instructions looked like this:
sudo gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.0/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.0/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28
where all of these locations match the tool locations correctly. However, when running bundle exec rspec spec/requests/static_pages.rb I still get this output:
/Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/nokogiri-1.5.9/lib/nokogiri.rb:28:in `require': dlopen(/Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/nokogiri-1.5.9/lib/nokogiri/nokogiri.bundle, 9): Library not loaded: /usr/local/lib/libxml2.2.dylib (LoadError) Referenced from: /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/nokogiri-1.5.9/lib/nokogiri/nokogiri.bundle Reason: Incompatible library version: nokogiri.bundle requires version 12.0.0 or later, but libxml2.2.dylib provides version 10.0.0 - /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/nokogiri-1.5.9/lib/nokogiri/nokogiri.bundle from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/nokogiri-1.5.9/lib/nokogiri.rb:28:in `<top (required)>' from /Users/alex/.rvm/gems/ ruby-1.9.3-p286@global /gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `require' from /Users/alex/.rvm/gems/ ruby-1.9.3-p286@global /gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `block (2 levels) in require' from /Users/alex/.rvm/gems/ ruby-1.9.3-p286@global /gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `each' from /Users/alex/.rvm/gems/ ruby-1.9.3-p286@global /gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `block in require' from /Users/alex/.rvm/gems/ ruby-1.9.3-p286@global /gems/bundler-1.3.4/lib/bundler/runtime.rb:59:in `each' from /Users/alex/.rvm/gems/ ruby-1.9.3-p286@global /gems/bundler-1.3.4/lib/bundler/runtime.rb:59:in `require' from /Users/alex/.rvm/gems/ ruby-1.9.3-p286@global /gems/bundler-1.3.4/lib/bundler.rb:132:in `require' from /Users/alex/Sites/harbingernews/config/application.rb:7:in `<top (required)>' from /Users/alex/Sites/harbingernews/config/environment.rb:2:in `require' from /Users/alex/Sites/harbingernews/config/environment.rb:2:in `<top (required)>' from /Users/alex/Sites/harbingernews/spec/spec_helper.rb:3:in `require' from /Users/alex/Sites/harbingernews/spec/spec_helper.rb:3:in `<top (required)>' from /Users/alex/Sites/harbingernews/spec/requests/static_pages_spec.rb:1:in `require' from /Users/alex/Sites/harbingernews/spec/requests/static_pages_spec.rb:1:in `<top (required)>' from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `load' from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `block in load_spec_files' from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `map' from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `load_spec_files' from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.9.0/lib/rspec/core/command_line.rb:22:in `run' from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:69:in `run' from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:10:in `block in autorun'
I tried all the steps that I found on the Internet (most of the links to creating and downloading various versions of libxml2, for example this one , but were unsuccessful My Gemfile and Gemfile.lock can be found here . If someone can help me, I would really appreciate I could not find any other cases online with this problem.
source share