xcode 无法设置 ruby​​ 环境 - 安装 fii gem 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17775115/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 03:37:04  来源:igfitidea点击:

can't setup ruby environment - installing fii gem error

rubyxcodemacosrubygemsgem

提问by bmalets

I'm trying to setup environtment for ruby project. But when I run 'bundle', I have error during installing 'fii' gem:

我正在尝试为 ruby​​ 项目设置环境。但是,当我运行“bundle”时,在安装“fii” gem 时出现错误:


    Installing ffi (1.8.1) 
    Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/bmalets/.rvm/rubies/ruby-1.9.3-p448/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.

    /Users/bmalets/.rvm/rubies/ruby-1.9.3-p448/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.

    Gem files will remain installed in /Users/bmalets/.rvm/gems/ruby-1.9.3-p448@api2/gems/ffi-1.8.1 for inspection.
    Results logged to /Users/bmalets/.rvm/gems/ruby-1.9.3-p448@api2/gems/ffi-1.8.1/ext/ffi_c/gem_make.out

    An error occurred while installing ffi (1.8.1), and Bundler cannot continue.
    Make sure that `gem install ffi -v '1.8.1'` succeeds before bundling.


My environment:

我的环境:

  • OS_X 10.8.4

  • ruby 1.9.3p448

  • Xcode 4.6.3

  • libffi-3.0.13

  • OS_X 10.8.4

  • 红宝石 1.9.3p448

  • Xcode 4.6.3

  • libffi-3.0.13

Please, help me to fix it.

请帮我修复它。

回答by gvalmon

Make sure that you have installed Apple Xcode and Command Line Tools (look at this screenshot):

确保你已经安装了 Apple Xcode 和命令行工具(看这个截图):

https://developer.apple.com/technologies/tools/

https://developer.apple.com/technologies/tools/

After that, don't forget to install libffi.

之后,不要忘记安装libffi。

1) if you are using homebrew

1)如果您使用的是自制软件

brew install libffi

2) if you are using macport

2) 如果您使用的是 macport

sudo port install libffi