5

当我在 Lion OS X 上运行应用程序时,我收到此错误:

Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/eventmachine-1.0.0/lib/eventmachine.rb:8:in `require': no such file to load -- rubyeventmachine (LoadError)
    from /Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/eventmachine-1.0.0/lib/eventmachine.rb:8:in `<top (required)>'
    from /Users/adam/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
    from /Users/adam/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /Users/adam/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
    from /Users/adam/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
    from /Users/adam/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
    from /Users/adam/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
    from /Users/adam/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
    from /Users/adam/rubydev/future_computers/config/application.rb:7:in `<top (required)>'
    from /Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/commands.rb:53:in `require'
    from /Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/commands.rb:53:in `block in <top (required)>'
    from /Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/commands.rb:50:in `tap'
    from /Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'adam

我真的不知道如何解决这个问题,我已将eventmachinegem 添加到 Gemfile 中,但它没有帮助......

你能帮我吗,请,如何解决它?

谢谢

4

6 回答 6

19

就我而言,这解决了它:

  • $ gem 卸载事件机器
  • 在提示符处告诉它卸载所有版本(它告诉你依赖项)
  • $捆绑安装

我正在阅读此https://github.com/eventmachine/eventmachine/issues/333。eventmachine 有问题,所以确保我得到最新版本似乎是个好主意。

于 2013-02-28T16:28:43.133 回答
9

对我来说,使用经过调整的配置从源代码编译 eventmachine 很有帮助。尝试:

如果已安装 eventmachine,请卸载它:

gem uninstall eventmachine

获取事件机器源:

git clone https://github.com/eventmachine/eventmachine.git
cd eventmachine

通过在之后添加来编辑ext/extconf.rbext/fastfilereader/extconf.rb文件CONFIG['CXX'] = "g++"require 'mkmf'

编译安装gem:

rake gem
gem install pkg/eventmachine-1.0.3.gem

现在 eventmachine 应该可以正常工作了:)

于 2014-01-06T12:27:58.683 回答
2

正如消息所说,最简单的解决方法就是require 'em/pure_ruby'. 我想你可以把它放在config/inlitializers文件夹中,你可以调用文件event_machine.rb

但它不会具有与 C 扩展相同的性能。

于 2013-02-12T02:42:30.973 回答
0

Providing another solution as I just wasted hours tracking this issue down. I was doing bundle install --deployment and then committing the result to a separate branch in git so I could deploy this branch straight to servers without having to do bundle install again.

The problem is that eventmachine has a .gitignore file in it which tells git to ignore all *.so files. Because of this when I was committing, the .so files didn't commit, and wouldn't show up as untracked in a git status. Also since the gemspec was present, bundle thought the package was completely installed.

My solution was to add a command as part of the build process to go and whack all the .gitignore files in the gems before committing.

于 2013-04-22T01:40:27.517 回答
0

您可能会在安装 gem 时发现各种错误,或者尝试寻找由于 ruby​​-devel 未安装而导致 ruby​​ 应用程序安装失败的解决方案。

我刚刚在我的 Kali linux 上安装了

sudo apt-get install ruby​​-dev

一切都解决了。我试图安装bettercap。

这个答案有帮助:https ://stackoverflow.com/a/4502672/6503117

于 2016-08-22T21:43:10.927 回答
0

bundle exec jekyll serve --livereload --trace当我在 Jekyll.4.2.1-Ruby.3.0.3p137(mingw)-Windows 上运行时,我遇到了这个错误。我跑了gem install eventmachine --platform=ruby,它编译了,C:\Ruby30-x64\lib\ruby\gems\3.0.0\gems\eventmachine-1.2.7但是当你运行bundle install它时,它也会创建C:\Ruby30-x64\lib\ruby\gems\3.0.0\gems\eventmachine-1.2.7-x64-mingw32。该命令bundle info eventmachine给了我C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/eventmachine-1.2.7-x64-mingw32,这在 Gemfile.lock 中以eventmachine (1.2.7-x64-mingw32). 所以我改变了那行eventmachine (1.2.7),然后输出bundle info eventmachine给了我C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/eventmachine-1.2.7,最后命令bundle exec jekyll serve --livereload --trace起作用了✔️

于 2022-01-30T19:08:01.330 回答