2013-02-12 78 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