0
votes

I am using Rvm and ruby 2.1.5p273.

Installed nokogiri by: gem install nokogiri

It installs perfectly:

Successfully installed nokogiri-1.6.5
Parsing documentation for nokogiri-1.6.5
Done installing documentation for nokogiri after 3 seconds
1 gem installed

After typing:

gem list | grep nokogiri

I get: nokogiri (1.6.5)

This is all on Mac Yosemite.

require 'nokogiri'

shows: LoadError: cannot load such file -- nokogiri/nokogiri

I searched all over SO and other forums, for hours no solution is working.

gem env

gives:

RubyGems Environment:

- RUBYGEMS VERSION: 2.4.5 - RUBY VERSION: 2.1.5 (2014-11-13 patchlevel 273) [x86_64-darwin14.0] - INSTALLATION DIRECTORY: /Users/mac/.rvm/gems/ruby-2.1.5 - RUBY EXECUTABLE: /Users/mac/.rvm/rubies/ruby-2.1.5/bin/ruby - EXECUTABLE DIRECTORY: /Users/mac/.rvm/gems/ruby-2.1.5/bin - SPEC CACHE DIRECTORY: /Users/mac/.gem/specs - SYSTEM CONFIGURATION DIRECTORY: /etc - RUBYGEMS PLATFORMS: - ruby - x86_64-darwin-14 - GEM PATHS: - /Users/mac/.rvm/gems/ruby-2.1.5 - /Users/mac/.rvm/gems/ruby-2.1.5@global - GEM CONFIGURATION: - :update_sources => true - :verbose => true - :backtrace => false - :bulk_threshold => 1000 - REMOTE SOURCES: - https://rubygems.org/ - SHELL PATH: - /Users/mac/.rvm/gems/ruby-2.1.5/bin - /Users/mac/.rvm/gems/ruby-2.1.5@global/bin - /Users/mac/.rvm/rubies/ruby-2.1.5/bin - /usr/local/heroku/bin - /Users/mac/.rbenv/shims - /Users/mac/.rbenv/bin - /Users/mac/.pyenv/bin - ./node_modules/.bin - /usr/local/bin - /usr/bin - /bin - /usr/sbin - /sbin - /usr/local/git/bin - /Users/mac/.gem/ruby/1.8/bin - /opt/nginx/sbin - /Users/mac/.bash_it/plugins/available/todo - /Users/mac/.rvm/bin - /Users/mac/android-sdks/platform-tools/

rvm info

gives

ruby-2.1.5:

system: uname: "Darwin macs-MacBook-Pro.local 14.0.0 Darwin Kernel Version 14.0.0: Fri Sep 19 00:26:44 PDT 2014; root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64" system: "osx/10.10/x86_64" bash: "/bin/bash => GNU bash, version 3.2.53(1)-release (x86_64-apple-darwin14)" zsh: "/usr/local/bin/zsh => zsh 5.0.5 (x86_64-apple-darwin13.0.0)"

rvm: version: "rvm 1.26.4 (latest) by Wayne E. Seguin , Michal Papis [https://rvm.io/]" updated: "1 month 25 days 17 hours 46 minutes 45 seconds ago" path: "/Users/mac/.rvm"

ruby: interpreter: "ruby" version: "2.1.5p273" date: "2014-11-13" platform: "x86_64-darwin14.0" patchlevel: "2014-11-13 revision 48405" full_version: "ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]"

homes: gem: "/Users/mac/.rvm/gems/ruby-2.1.5" ruby: "/Users/mac/.rvm/rubies/ruby-2.1.5"

binaries: ruby: "/Users/mac/.rvm/rubies/ruby-2.1.5/bin/ruby" irb: "/Users/mac/.rvm/rubies/ruby-2.1.5/bin/irb" gem: "/Users/mac/.rvm/rubies/ruby-2.1.5/bin/gem" rake: "/Users/mac/.rvm/gems/ruby-2.1.5/bin/rake"

environment: PATH: "/Users/mac/.rvm/gems/ruby-2.1.5/bin:/Users/mac/.rvm/gems/ruby-2.1.5@global/bin:/Users/mac/.rvm/rubies/ruby-2.1.5/bin:/usr/local/heroku/bin:/Users/mac/.rbenv/shims:/Users/mac/.rbenv/bin:/Users/mac/.pyenv/bin:./node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/Users/mac/.gem/ruby/1.8/bin:/opt/nginx/sbin:/Users/mac/.bash_it/plugins/available/todo:/Users/mac/.rvm/bin:/Users/mac/android-sdks/platform-tools/" GEM_HOME: "/Users/mac/.rvm/gems/ruby-2.1.5" GEM_PATH: "/Users/mac/.rvm/gems/ruby-2.1.5:/Users/mac/.rvm/gems/ruby-2.1.5@global" MY_RUBY_HOME: "/Users/mac/.rvm/rubies/ruby-2.1.5" IRBRC: "/Users/mac/.rvm/rubies/ruby-2.1.5/.irbrc" RUBYOPT: "" gemset: ""

2
how are you running the code?Uri Agassi
@UriAgassi : Running it in irbY M
try running bundle exec irbUri Agassi
But I am not running this inside any project.. so this just shows: Could not locate Gemfile . As expected, if I am not wrong.Y M
Append the output of gem env and rvm info to your question please.the Tin Man

2 Answers

0
votes

Can you try the following stuffs:

brew update
xcode-select --install
brew install libiconv
brew link libiconv

Then try these:

 gem pristine nokogiri
 gem install nokogiri -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.14
 or
 bundle install

Also please check if you are properly loaded your right gemset/ruby version.

-2
votes

I also had the same problem and just adding sudo worked perfectly fine with me

i.e Your command to install nokogiri is : gem install nokogiri now try adding sudo that will be like the following

sudo gem install nokogiri