Ruby-on-rails ffi 上的捆绑更新失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10575679/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bundle update fails on ffi
提问by Kyle Decot
I'm attempting to do a bundle updateon my rails application but I get the following error:
我试图bundle update在我的 rails 应用程序上做一个,但我收到以下错误:
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>'
Any ideas?
有任何想法吗?
回答by Kevin Bedell
I ran into a problem similar to this yesterday.
我昨天遇到了类似的问题。
I was able to resolve it using these steps:
我能够使用以下步骤解决它:
https://github.com/carlhuda/bundler/blob/1-0-stable/ISSUES.md
https://github.com/carlhuda/bundler/blob/1-0-stable/ISSUES.md
Essentially, there was a problem with my bundle and clearing things out and rebuilding things from scratch resolved it.
从本质上讲,我的包有问题,清理东西并从头开始重建解决了它。
The steps are repeated here:
这里重复这些步骤:
# 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
Although, given the message in the output text:
虽然,鉴于输出文本中的消息:
You have to install development tools first.
您必须先安装开发工具。
That makes me think you just may not have installed the Apple Xcode Developer Tools. Have you checked that? (I believe they're available in the Mac App Store.)
这让我觉得您可能没有安装Apple Xcode Developer Tools。你检查过吗?(我相信它们可以在 Mac App Store 中找到。)
回答by Lasse Bunk
For Xcode 5 and later:
对于 Xcode 5 及更高版本:
$ xcode-select --install
to install the Command Line Tools.
安装命令行工具。
回答by kiero
Once installed gcc-4.2 from brew, you need to create symlink of it:
从 brew 安装 gcc-4.2 后,您需要创建它的符号链接:
ln -s /usr/bin/gcc /usr/bin/gcc-4.2
回答by DiS
Just in case try to run
以防万一尝试运行
sudo /usr/bin/gcc
须藤/usr/bin/gcc
You'll probably see license agreement, so scroll thgough it, type "agree" and try to install gem again.
你可能会看到许可协议,所以滚动它,输入“同意”并再次尝试安装 gem。
回答by theotherjim
Please note:
请注意:
If you have recently updated Xcode, you may just need to open Xcode and accept the latest agreement.
如果您最近更新了 Xcode,您可能只需要打开 Xcode 并接受最新的协议。
I had the same issue and had recently installed an update to Xcode (v6.1) and solved it with these steps:
我遇到了同样的问题,最近安装了 Xcode (v6.1) 的更新并通过以下步骤解决了这个问题:
- open Xcode
- accept new agreement
- rerun bundle update
- 打开Xcode
- 接受新协议
- 重新运行包更新
回答by Konstantin Pereiaslov
For me I just didn't have gcc installed, solve in Ubuntu by:
对我来说,我只是没有安装 gcc,在 Ubuntu 中通过以下方式解决:
sudo apt install build-essential
回答by Dan Sandland
Installing "Command Line Tools" via Xcode did the trick.
通过 Xcode 安装“命令行工具”可以解决问题。
If you have Xcode 4.5 open Preferences> Downloads> Select Componentstab and click Installnext to Command Line Tools.
如果您有 Xcode 4.5,请打开Preferences> Downloads> Select Components选项卡,然后单击Command Line Tools旁边的Install。
Although I installed from Xcode, you can also download the package without it from Apple's Developer Downloads and searching for "Command Line Tools".
虽然我是从 Xcode 安装的,但您也可以从Apple 的开发人员下载并搜索 "Command Line Tools" 下载没有它的软件包。
回答by i.bajrai
I had to accept the Xcode User licence:
我必须接受 Xcode 用户许可证:
Running sudo xcrun cc should bring up the cli version of the Xcode license agreement. Another option is to open Xcode.app and agree in the GUI.
运行 sudo xcrun cc 应该会显示 Xcode 许可协议的 cli 版本。另一种选择是打开 Xcode.app 并在 GUI 中同意。
Possibly caused by updating OSX.
可能是由更新 OSX 引起的。
http://blog.tomhennigan.co.uk/post/62238548037/agreeing-to-the-xcode-license-from-the-command
http://blog.tomhennigan.co.uk/post/62238548037/agreeing-to-the-xcode-license-from-the-command
回答by Alex M.
Ubuntu Trusty LTS 14.04
Ubuntu Trusty LTS 14.04
Needed to switch from ruby 2.2.1 to 2.3.0 to support newer gem versions in Rails app.
需要从 ruby 2.2.1 切换到 2.3.0 以支持 Rails 应用程序中更新的 gem 版本。
Solution:
解决方案:
rvm get stablervm remove 2.3.0rvm install 2.3.0bundle install
rvm get stablervm remove 2.3.0rvm install 2.3.0bundle install
回答by lfender6445
Mac OSx 10.10.2 yosemite
Mac OSx 10.10.2 优胜美地
CC=/usr/bin/i686-apple-darwin11-llvm-gcc-4.2 gem install ffi
and thats it -check that you have 4.2 compiler in /usr/binthat you can hook into
就是这样 - 检查你是否有 4.2 编译器/usr/bin,你可以挂钩
ls /usr/bin|grep gcc|grep 4.2
You do not have to wipe out all of your local gems or override symlinks to do this- its a waste of time and will likely create more problems then it solves.
您不必清除所有本地 gem 或覆盖符号链接来执行此操作- 这是浪费时间,并且可能会产生更多问题然后解决。
please note, your bin path may be different if you needed to install via brew
请注意,如果您需要通过 brew 安装,您的 bin 路径可能会有所不同
brew install apple-gcc42

