2012-05-13 49 views
22

我試圖做我的Rails應用程序bundle update但我得到以下錯誤:捆綁更新失敗的FFI

Installing ffi (1.0.11) with native extensions Unfortunately, a fatal error has occurred. Please report this error to the Bundler issue tracker at https://github.com/carlhuda/bundler/issues so that we can fix it. Thanks! 
/Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:552:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) 

     /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb 
checking for ffi.h... *** extconf.rb failed *** 
Could not create Makefile due to some reason, probably lack of 
necessary libraries and/or headers. Check the mkmf.log file for more 
details. You may need configuration options. 

Provided configuration options: 
    --with-opt-dir 
    --with-opt-include 
    --without-opt-include=${opt-dir}/include 
    --with-opt-lib 
    --without-opt-lib=${opt-dir}/lib 
    --with-make-prog 
    --without-make-prog 
    --srcdir=. 
    --curdir 
    --ruby=/Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/bin/ruby 
    --with-ffi_c-dir 
    --without-ffi_c-dir 
    --with-ffi_c-include 
    --without-ffi_c-include=${ffi_c-dir}/include 
    --with-ffi_c-lib 
    --without-ffi_c-lib=${ffi_c-dir}/lib 
    --with-libffi-config 
    --without-libffi-config 
    --with-pkg-config 
    --without-pkg-config 
/Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError) 
You have to install development tools first. 
    from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp' 
    from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:931:in `block in have_header' 
    from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for' 
    from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone' 
    from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in `open' 
    from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone' 
    from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in `open' 
    from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:280:in `postpone' 
    from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for' 
    from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:930:in `have_header' 
    from extconf.rb:9:in `<main>' 


Gem files will remain installed in /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/ffi-1.0.11 for inspection. 
Results logged to /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/ffi-1.0.11/ext/ffi_c/gem_make.out 
    from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:530:in `block in build_extensions' 
    from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:505:in `each' 
    from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:505:in `build_extensions' 
    from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:180:in `install' 
    from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/source.rb:90:in `block in install' 
    from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/rubygems_integration.rb:82:in `preserve_paths' 
    from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/source.rb:89:in `install' 
    from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:73:in `block in install_gem_from_spec' 
    from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/rubygems_integration.rb:97:in `with_build_args' 
    from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:72:in `install_gem_from_spec' 
    from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:56:in `block in run' 
    from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:55:in `run' 
    from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:12:in `install' 
    from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/cli.rb:271:in `update' 
    from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/vendor/thor/task.rb:22:in `run' 
    from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task' 
    from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/vendor/thor.rb:263:in `dispatch' 
    from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/vendor/thor/base.rb:386:in `start' 
    from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/bin/bundle:13:in `<top (required)>' 
    from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/bin/bundle:19:in `load' 
    from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/bin/bundle:19:in `<main>' 

任何想法?

回答

26

昨天遇到類似這個問題。

我能夠使用這些步驟來解決它:

https://github.com/carlhuda/bundler/blob/1-0-stable/ISSUES.md

從本質上講,有一個與我的包和清除的東西出來,並從頭開始重建的事情解決了這一個問題。在此重複

步驟:

# remove user-specific gems and git repos 
rm -rf ~/.bundle/ ~/.gem/ 

# remove system-wide git repos and git checkouts 
rm -rf $GEM_HOME/bundler/ $GEM_HOME/cache/bundler/ 

# remove project-specific settings and git repos 
rm -rf .bundle/ 

# remove project-specific cached .gem files 
rm -rf vendor/cache/ 

# remove the saved resolve of the Gemfile 
rm -rf Gemfile.lock 

# try to install one more time 
bundle install 

雖然,考慮到輸出文本消息:

You have to install development tools first.

這讓我覺得你剛纔可能沒有安裝Apple Xcode Developer Tools。你檢查過了嗎? (我相信他們是在Mac App Store中提供。)

+2

我有安裝的Xcode但現在看來,打包器不能找到它由於某種原因......我想你的建議,以及安裝https://github.com/kennethreitz/osx-gcc-installer和現在一切正常。謝謝您的幫助!我打算給你賞金,但是這讓我等了23個小時。我會把它給你然後:) –

+0

謝謝!非常感激! –

+0

thx!太好了! – Madao

10

一旦安裝GCC-4.2從沖泡,你需要創建它的符號鏈接:通過Xcode的

ln -s /usr/bin/gcc /usr/bin/gcc-4.2 
+0

這是我終於安裝eventmachine gem的最終目的。我曾嘗試更新rvm,重新安裝紅寶石,確保命令行工具在XCode(4.6)和其他一些東西。我嘗試設置CC =/usr/local/bin/gcc-4.2,但沒有這樣做,但是現在看起來它最終編譯爲llvm-gcc「/usr/bin/[email protected]>/usr/bin/gcc「和」/ usr/bin/gcc @ - > llvm-gcc-4.2「。至於爲什麼,我完全困惑,但它工作。希望它不會弄亂其他任何東西,比如brew安裝... – mmrobins

+0

對我來說,我只是簡單地更新了我的XCode和命令行工具,然後將您的建議更改爲符號鏈接到/usr/bin/gcc-4.2。謝謝!我不會想出這一點。 –

+0

嘗試安裝XCode命令行工具並且未成功運行'gem install ffi'。添加符號鏈接後,按照@kiero ffi-1.9.3的建議安裝好。謝謝! – Lenart

10

對於Xcode的5及更高版本:

$ xcode-select --install 

安裝命令行工具。

+0

這有幫助!謝謝! –

5

以防萬一嘗試運行

須藤的/ usr/bin中/ GCC

你可能會看到許可協議,所以滾動thgough它,鍵入「同意」,並嘗試重新安裝寶石。

+0

你意識到這個問題有多大?它有一個公認的答案 – 2014-09-25 03:12:44

+3

這實際上解決了我的問題,所以謝謝你的答案。 – rubiii

+1

這對我有用。謝啦!以上所有解決方案都沒有解決它,但是這樣做。幹得不錯! –

5

請注意:

如果您最近更新的Xcode,你可能只需要打開Xcode和接受最新協議

我有同樣的問題,並且最近安裝了更新到Xcode(v6。1),並通過以下步驟來解決它:

  1. 開放的Xcode
  2. 接受新協議
  3. 重新運行包更新
0

MAC OSX 10.10.2約塞米蒂

CC=/usr/bin/i686-apple-darwin11-llvm-gcc-4.2 gem install ffi 

和多數民衆贊成它 - 確認你有4.2編譯器/usr/bin你ç一個勾成

ls /usr/bin|grep gcc|grep 4.2 

你不必消滅所有本地寶石或覆蓋符號鏈接做到這一點 - 時間的浪費,可能會帶來更多的問題,然後解決了。

export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk 
bundle update 

ffi.h${SDKROOT}/usr/include/ffi/ffi.h被發現:

請注意,如果您需要通過BREW

brew install apple-gcc42 
0

另外的方法來安裝你的bin路徑可能會有所不同。

0

Ubuntu的LTS忠實的14.04

需要從紅寶石2.2.1切換到2.3.0支持Rails應用新的gem版本。

解決方案:

  1. rvm get stable
  2. rvm remove 2.3.0
  3. rvm install 2.3.0
  4. bundle install
1

對我來說,我只是沒有安裝GCC,通過在Ubuntu解決:

sudo apt install build-essential