Rails – 无法运行app:无法加载EventMachine C扩展;
当我在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 `' 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 `' 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 ' 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 `' from script/rails:6:in `require' from script/rails:6:in `'adam
我真的不知道如何解决这个问题,我已将eventmachine
gem添加到Gemfile中,但它没有帮助……
你能帮帮我,怎么解决?
谢谢
在我的情况下,这修复了它:
- $ gem uninstall eventmachine
- 在提示符下告诉它卸载所有版本(它告诉你有关依赖项)
- $ bundle install
我正在阅读这篇https://github.com/eventmachine/eventmachine/issues/333 。 事件机器存在问题,因此确保我获得最新版本似乎是一个好主意。
对我来说,从具有调整配置的来源编译eventmachine有帮助。 尝试:
如果已经安装了eventmachine,请将其卸载:
gem uninstall eventmachine
获取eventmachine来源:
git clone https://github.com/eventmachine/eventmachine.git cd eventmachine
通过在require 'mkmf'
之后添加CONFIG['CXX'] = "g++"
编辑ext/extconf.rb
和ext/fastfilereader/extconf.rb
文件
编译并安装gem:
rake gem gem install pkg/eventmachine-1.0.3.gem
现在eventmachine应该工作得很好:)
消息所说的最简单的解决方法就是require 'em/pure_ruby'
。 我想你可以将它放在config / inlitializers文件夹中,你可以调用event_machine.rb文件
但它不会具有与C扩展相同的性能。
提供另一种解决方案因为我浪费时间来追踪这个问题。 我正在进行bundle install --deployment
,然后将结果提交到git中的一个单独的分支,这样我就可以直接将这个分支部署到服务器而无需再次进行bundle install
。
问题是eventmachine中有一个.gitignore
文件,告诉git忽略所有*.so
文件。 因为当我提交时, .so
文件没有提交,并且不会在git status
显示为未跟踪。 此外,由于gemspec存在,bundle认为包已完全安装。
我的解决方案是添加一个命令作为构建过程的一部分,以便在提交之前对gem中的所有.gitignore
文件进行重击。
您可能会在安装gem时遇到各种错误,或者尝试找到因ruby-devel未安装而导致ruby应用程序安装失败的解决方案。
我刚安装在我的Kali linux上
sudo apt-get install ruby-dev
一切都解决了。 我试图安装bettercap。
这个答案有所帮助: https : //stackoverflow.com/a/4502672/6503117