0

Ruby 1.9.3 非常简单的代码和我无法处理的非常简单的问题:

gem list --local
nokogiri (1.5.5)

gem q --local
nokogiri (1.5.5)

但是一个红宝石脚本(不是Rails):

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

给我

/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]

我知道没有必要使用require 'rubygems',但即使我这样做,它也不起作用。

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
4

2 回答 2

3

这是因为错误的 Sublime Text 构建系统。正确的在这里How to run ruby​​ files in sublime-text-2

于 2012-10-31T12:45:06.093 回答
-2

您需要将 Nokogiri 添加到 Gemfile(使用 gem 'nokogiri' 行)。

于 2012-10-31T11:32:42.443 回答