2013-02-12 79 views
4

当我运行在Lion上OS X的应用程序,我得到这个错误:Rails - 无法运行应用程序:无法加载EventMachine C扩展;

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/[email protected]/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require' 
    from /Users/adam/.rvm/gems/[email protected]/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require' 
    from /Users/adam/.rvm/gems/[email protected]/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each' 
    from /Users/adam/.rvm/gems/[email protected]/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require' 
    from /Users/adam/.rvm/gems/[email protected]/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each' 
    from /Users/adam/.rvm/gems/[email protected]/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require' 
    from /Users/adam/.rvm/gems/[email protected]/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 

我真的不知道如何解决这个问题,我已经添加了eventmachine宝石到的Gemfile,但它没”帮助...

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

谢谢

+0

“捆绑安装”有任何错误吗? – 2013-02-12 02:38:48

+0

'bundle install'没有任何错误。 – user984621 2013-02-12 10:03:11

回答

2

的最简单的解决作为消息说,仅仅是require 'em/pure_ruby'。我想你可以把这个在配置/ inlitializers文件夹,你可以调用该文件event_machine.rb

但它不会有相同的性能,因为C扩展。

+0

但是在哪里可以找到并下载该文件? – user984621 2013-02-12 09:32:39

+0

在config/initializers文件夹中创建它 – 2013-02-12 16:40:59

+0

不,不适用于我。 – digitig 2015-04-09 17:49:38

0

提供另一个解决方案,因为我只是浪费了几个小时来追踪这个问题。我在做bundle install --deployment,然后将结果提交给git中的单独分支,所以我可以直接将此分支部署到服务器,而无需再次执行bundle install

问题是,eventmachine有一个.gitignore文件,它告诉git忽略所有*.so文件。由于这一点,当我提交时,.so文件没有提交,并且不会在git status中显示为untracked。此外,由于gemspec出现,捆绑包认为该包已完全安装。

我的解决方案是添加一个命令作为构建过程的一部分,并在提交之前将所有.gitignore文件重新打包。

+1

使用git来存储大量的二进制文件可能会导致痛苦 – 2013-11-22 23:56:37

+1

@BlakeMiller是的,我们最终放弃了这种方法,现在正在构建tarball。 – Patrick 2013-11-23 00:27:54

8

对我来说,编译来自tweaked config来源的eventmachine帮助。尝试:

卸载EventMachine的,如果它已经安装:

gem uninstall eventmachine 

取EventMachine的来源:

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

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

编译并安装宝石:

rake gem 
gem install pkg/eventmachine-1.0.3.gem 

现在EventMachine的应该只是罚款:)

+0

这为我工作! – hananamar 2014-10-11 10:01:10

+0

这工作for mailcatcher启动,但不知何故打破了我的软件包安装..计算该atm – 2014-11-08 13:55:46

+0

检出v1.0.3并执行编辑。现在我得到了'不知道如何构建任务'native:eventmachine:x86-mingw32'(请参阅 - 任务)' – 2017-12-27 21:33:05

0

在安装宝石或试图找到解决你的Ruby应用程序安装失败是由于红宝石devel的未安装您可能会发现各种错误。

我刚刚安装在我的卡里的Linux与

sudo易于得到安装Ruby-dev的

,一切都解决了。我试图安装更好的帽子。

此答案帮助:https://stackoverflow.com/a/4502672/6503117