无法在 Rails 控制台中加载 Ruby EventMachine - 没有要加载的文件

发布于 2024-10-02 05:16:45 字数 1894 浏览 3 评论 0原文

我无法在简单的测试程序中需要 EventMachine。我正在运行 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 以及所有的 gem,但我无法完成这项工作。有人能指出我正确的方向吗?

-拉斯

I'm not able to require EventMachine in a simple test program. I'm running Ruby 1.9.2 (x86_64-darwin10.4.0) and Rails 3.0.1. EventMachine is installed (via gem install eventmachine) and gem knows it:

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)

Yet, when I start the rails console (via rails console) and simply require eventmachine, it blows up:


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>'

I get the same result trying to run a method in a class that requires EventMachine. EventMachine built without error. I've uninstalled EventMachine and Ruby and all the gems over and over but I can't make this work. Can anyone point me in the right direction?

-Russ

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

得不到的就毁灭 2024-10-09 05:16:45

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

gem "eventmachine"

(安装任何未通过 <代码>捆绑安装)。

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

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

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

Rails 3 uses Bundler by default, what this means is that you need to specify all your dependencies in the Gemfile like this:

gem "eventmachine"

(install any not installed via bundle install).

Bundler handles dependency management, which means you can lock down your gem versions, and avoid conflicts nicely, but conversely, this means it won't load anything that isn't specified in your Gemfile.

This also means if you want to run your development webserver on something nicer than webrick, you may want to add something like this to your gemfile too

group :development do
  gem 'mongrel'
  gem 'ruby-debug'
end
一念一轮回 2024-10-09 05:16:45

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

Did you try putting it in your rails app's gemfile and doing a bundle install?

痴情 2024-10-09 05:16:45

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

观众。
https://github.com/eventmachine/eventmachine/blob /master/ext/extconf.rb#L78-L90

Remove Ruby x64 in windows .
Reinstall Ruby x86.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文