2

我正在尝试使用 Rails 2.3.4 在 Ruby 1.9 中启动控制台(irb)。我安装了两个版本的 Ruby(1.9 和 1.8.6),我通过调用运行 Ruby 1.9:rake19、ruby19、gem19...等

它们在除此之外的所有情况下都能正常工作!似乎它试图加载 Ruby 1.8!你知道我怎么能改变它吗?

Macintosh-10:favquote tammam56$ ruby19 script/console
Loading development environment (Rails 2.3.4)
/Users/tammam56/rubydev/favquote/config/../vendor/rails/railties/lib/rails/vendor_gem_source_index.rb:1:in `require': no such file to load -- rubygems (LoadError)
    from /Users/tammam56/rubydev/favquote/config/../vendor/rails/railties/lib/rails/vendor_gem_source_index.rb:1
    from /Users/tammam56/rubydev/favquote/config/../vendor/rails/railties/lib/rails/gem_dependency.rb:1:in `require'
    from /Users/tammam56/rubydev/favquote/config/../vendor/rails/railties/lib/rails/gem_dependency.rb:1
    from /Users/tammam56/rubydev/favquote/config/../vendor/rails/railties/lib/initializer.rb:10:in `require'
    from /Users/tammam56/rubydev/favquote/config/../vendor/rails/railties/lib/initializer.rb:10
    from /Users/tammam56/rubydev/favquote/config/boot.rb:45:in `require'
    from /Users/tammam56/rubydev/favquote/config/boot.rb:45:in `load_initializer'
    from /Users/tammam56/rubydev/favquote/config/boot.rb:38:in `run'
    from /Users/tammam56/rubydev/favquote/config/boot.rb:11:in `boot!'
    from /Users/tammam56/rubydev/favquote/config/boot.rb:110
    from /Users/tammam56/rubydev/favquote/config/environment.rb:8:in `require'
    from /Users/tammam56/rubydev/favquote/config/environment.rb:8
    from /opt/local/lib/ruby/1.8/irb/init.rb:252:in `require'
    from /opt/local/lib/ruby/1.8/irb/init.rb:252:in `load_modules'
    from /opt/local/lib/ruby/1.8/irb/init.rb:250:in `each'
    from /opt/local/lib/ruby/1.8/irb/init.rb:250:in `load_modules'
    from /opt/local/lib/ruby/1.8/irb/init.rb:21:in `setup'
    from /opt/local/lib/ruby/1.8/irb.rb:54:in `start'
    from /opt/local/bin/irb:13

谢谢,

4

1 回答 1

3

这是因为脚本/控制台正在调用 irb (1.8)。假设您有 irb19 用于 ruby​​ 1.9,您可以这样做:

script/console --irb='irb19'

但是,rails gem 可能仍然存在问题。如果是这样,我建议使用rvm来管理不同的 ruby​​。使用 rvm 时,您需要为 ruby​​ 1.9 和 1.8 分别安装 gem。

于 2009-11-14T10:04:10.563 回答