无法使用Ruby 1.9和Rails 2.3.4启动脚本/控制台

时间:2009-11-14 06:38:30

标签: ruby-on-rails ruby-1.9 irb

我正在尝试使用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

谢谢,

1 个答案:

答案 0 :(得分:3)

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

script/console --irb='irb19'

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