首页 文章

无法在Rails控制台中加载Ruby EventMachine - 无法加载此类文件

提问于
浏览
1

我'm not able to require EventMachine in a simple test program. I'运行Ruby 1.9.2(x86_64-darwin10.4.0)和Rails 3.0.1 . EventMachine已安装(通过 gem install eventmachine ),gem知道它:

gem list --local

*** LOCAL GEMS ***

abstract (1.0.0)
...
erubis (2.6.6)
eventmachine (0.12.10)
i18n (0.4.2)
...
tzinfo (0.3.23)

然而,当我启动rails控制台(通过 rails console )并且只需要eventmachine时,它会爆炸:

ruby-1.9.2-p0 > require 'rubygems'
 => nil 
ruby-1.9.2-p0 > require 'eventmachine'
LoadError: no such file to load -- eventmachine
    from /Users/russ/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in 'require'
    from /Users/russ/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in 'block in require'
    from /Users/russ/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:225:in 'block in load_dependency'
    from /Users/russ/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:591:in 'new_constants_in'
    from /Users/russ/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:225:in 'load_dependency'
    from /Users/russ/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in 'require'
    from (irb):2
    from /Users/russ/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.1/lib/rails/commands/console.rb:44:in 'start'
    from /Users/russ/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.1/lib/rails/commands/console.rb:8:in 'start'
    from /Users/russ/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.1/lib/rails/commands.rb:23:in '<top (required)>'
    from script/rails:6:in 'require'
    from script/rails:6:in '<main>'

尝试在需要EventMachine的类中运行方法时得到相同的结果 . EventMachine构建没有错误 . 我已经一遍又一遍地卸载了EventMachine和Ruby以及所有的宝石,但我无法完成这项工作 . 谁能指出我正确的方向?

-Russ

3 回答

  • 0

    Rails 3默认使用Bundler,这意味着您需要在_1057427中指定所有依赖项,如下所示:

    gem "eventmachine"

    (通过 bundle install 安装任何未安装的) .

    Bundler处理依赖关系管理,这意味着您可以锁定gem版本,并避免冲突,但相反,这意味着它不会加载Gemfile中未指定的任何内容 .

    这也意味着如果你想在比webrick好的东西上运行你的开发网络服务器,你可能想要在你的gemfile中添加这样的东西

    group :development do
      gem 'mongrel'
      gem 'ruby-debug'
    end
    
  • 7

    您是否尝试将其放入rails应用程序的gemfile并进行捆绑安装?

  • 0

    在Windows中删除Ruby x64 . 重新安装Ruby x86 .

    查看者 . https://github.com/eventmachine/eventmachine/blob/master/ext/extconf.rb#L78-L90

相关问题