ruby-on-railsrubyxmlnokogirilibxml-ruby

libxml/nokogiri not working: cannot load such file -- libxml rails


I am trying to use libxml in my rails app. However I get the error:

cannot load such file -- libxml

as you can see libxml is installed in my gems:

Fetching gem metadata from https://rubygems.org/...........
Resolving dependencies...
Using rake 10.3.2
Using i18n 0.6.11
Using json 1.8.1
Using minitest 5.4.0
Using thread_safe 0.3.4
Using tzinfo 1.2.2
Using activesupport 4.1.1
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.1
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.1.1
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.1.1
Using activemodel 4.1.1
Using arel 5.0.1.20140414130214
Using activerecord 4.1.1
Using bundler 1.6.2
Using coffee-script-source 1.7.1
Using execjs 2.2.1
Using coffee-script 2.3.0
Using thor 0.19.1
Using railties 4.1.1
Using coffee-rails 4.0.1
Using hike 1.2.3
Using multi_json 1.10.1
Using jbuilder 2.1.3
Using jquery-rails 3.1.1
Using libxml-ruby 2.7.0
Using pg 0.17.1
Using tilt 1.4.1
Using sprockets 2.11.0
Using sprockets-rails 2.1.3
Using rails 4.1.1
Using rdoc 4.1.1
Using sass 3.2.19
Using sass-rails 4.0.3
Using sdoc 0.4.1
Using spring 1.1.3
Using turbolinks 2.2.3
Using uglifier 2.5.3
Your bundle is updated!

I try to use it like this in my controller class:

require 'libxml'
  def import
    some code that it doesnt even reach
  end

Does anyone know what I can do to make it work?

Using it on Mac OSX 10.9.x - Rails 4 - Ruby 2.1.1

UPDATE I installed nokogiri instead of libxml following the steps in http://nokogiri.org/tutorials/installing_nokogiri.html and added the gem to the gem file: gem 'nokogiri'

unfortunately the load error persists but now for nokogiri: cannot load such file -- nokogiri


Solution

  • Solved the problem: For some reason I had two different gem paths pointing ruby2.1.0 and Ruby 2.1.1. Including Ruby '2.1.1' in the gemfile solved the problem