Alan Coromano
Alan Coromano

Reputation: 26048

Ruby 1.9.3 - cannot load such file for some reason

Ruby 1.9.3 Very simple code and very simple question I can't deal with:

gem list --local
nokogiri (1.5.5)

gem q --local
nokogiri (1.5.5)

But a ruby script (not Rails):

require 'nokogiri'
doc = Nokogiri.XML("some valid xml....")

gives me

/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- nokogiri (LoadError)
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/alex/test.rb:3:in `<main>'
[Finished in 0.1s with exit code 1]

I'm aware that it's not necessary to use require 'rubygems', but even when I do that, it does not work either.

gem environment
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.24
  - RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/alex/.rvm/gems/ruby-1.9.3-p194
  - RUBY EXECUTABLE: /home/alex/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
  - EXECUTABLE DIRECTORY: /home/alex/.rvm/gems/ruby-1.9.3-p194/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/alex/.rvm/gems/ruby-1.9.3-p194
     - /home/alex/.rvm/gems/ruby-1.9.3-p194@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/


gem which nokogiri
/home/alex/.rvm/gems/ruby-1.9.3-p194/gems/nokogiri-1.5.5/lib/nokogiri.rb

Upvotes: 0

Views: 1349

Answers (2)

Alan Coromano
Alan Coromano

Reputation: 26048

It happens because of the wrong Sublime Text build system. The right one is here How to run ruby files in sublime-text-2

Upvotes: 3

vijikumar
vijikumar

Reputation: 1815

you need to add Nokogiri to the Gemfile (with the line gem 'nokogiri').

Upvotes: -2

Related Questions