【问题标题】:Can't install ffi 1.9.0 via rvm bundle install - OSX 10.8.4无法通过 rvm bundle install 安装 ffi 1.9.0 - OSX 10.8.4
【发布时间】:2013-08-24 21:59:49
【问题描述】:

在 Macbook Pro 上使用 OSX 10.8.4 和 homebrew、xcode(带有命令行工具)和 libffi。

我已经安装了 rvm 和 ruby​​-1.9.3-p448 并且有一个名为 omega.ecoop 的 gemset。有一个 gemfile 列出了这个项目所需的 gem。但是,在运行捆绑检查后,我无法安装它们:

Bundler can't satisfy your Gemfile's dependencies.

这是正确的,因为它们没有安装。所以我使用:

bundle install

产生以下内容:

Sams-MacBook-Pro:ecoop Sam$ bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using addressable (2.3.5) 
Using chunky_png (1.2.8) 
Using fssm (0.2.10) 
Using sass (3.2.10) 
Using compass (0.12.2) 
Using breakpoint (2.0.6) 
Using coderay (1.0.9) 
Using compass-blend-modes (0.0.2) 
Using color-schemer (0.2.5) 
Using compass-normalize (1.4.3) 
Using compass-rgbapng (0.2.1) 
Using compass-validator (3.0.1) 
Using css_parser (1.3.5) 
Using eventmachine (1.0.3) 
Using http_parser.rb (0.5.3) 
Using em-websocket (0.5.0) 
Installing ffi (1.9.0) 

一切顺利,直到:

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

    /Users/Sam/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb 
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... no
checking for rb_thread_blocking_region()... yes
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
checking for ffi_prep_cif_var()... no
creating extconf.h
creating Makefile

make
mkdir -p "/Users/Sam/.rvm/gems/ruby-1.9.3-p448@omega.ecoop/gems/ffi-1.9.0/ext/ffi_c"/libffi-x86_64; (if [ ! -f "/Users/Sam/.rvm/gems/ruby-1.9.3-p448@omega.ecoop/gems/ffi-1.9.0/ext/ffi_c"/libffi-x86_64/Makefile ]; then echo "Configuring libffi for x86_64"; cd "/Users/Sam/.rvm/gems/ruby-1.9.3-p448@omega.ecoop/gems/ffi-1.9.0/ext/ffi_c"/libffi-x86_64 && env CC=" gcc-4.6" CFLAGS="-arch x86_64 " LDFLAGS="-arch x86_64" "/Users/Sam/.rvm/gems/ruby-1.9.3-p448@omega.ecoop/gems/ffi-1.9.0/ext/ffi_c/libffi"/configure --disable-static --with-pic=yes --disable-dependency-tracking --host=x86_64-apple-darwin > /dev/null; fi); env MACOSX_DEPLOYMENT_TARGET=10.4 make -C "/Users/Sam/.rvm/gems/ruby-1.9.3-p448@omega.ecoop/gems/ffi-1.9.0/ext/ffi_c"/libffi-x86_64
Configuring libffi for x86_64
configure: WARNING: if you wanted to set the --build type, don't use --host.
    If a cross compiler is detected then cross compile mode will be used
configure: error: in `/Users/Sam/.rvm/gems/ruby-1.9.3-p448@omega.ecoop/gems/ffi-1.9.0/ext/ffi_c/libffi-x86_64':
configure: error: C compiler cannot create executables
See `config.log' for more details
make[1]: *** No targets specified and no makefile found.  Stop.
make: *** ["/Users/Sam/.rvm/gems/ruby-1.9.3-p448@omega.ecoop/gems/ffi-1.9.0/ext/ffi_c"/libffi-x86_64/.libs/libffi_convenience.a] Error 2


Gem files will remain installed in /Users/Sam/.rvm/gems/ruby-1.9.3-p448@omega.ecoop/gems/ffi-1.9.0 for inspection.
Results logged to /Users/Sam/.rvm/gems/ruby-1.9.3-p448@omega.ecoop/gems/ffi-1.9.0/ext/ffi_c/gem_make.out

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

这个命令也不起作用(gem install ffi -v '1.9.0'),我得到同样的错误。我试过了:

sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2

我已阅读:

can't setup ruby environment - installing fii gem error

Bundle update fails on ffi

Bundle update fails on ffi

Error installing ffi

gem install ffi -v '1.1.5' osx 10.8

仍然没有运气。我按照本指南设置 RVM:

http://portertech.ca/2010/03/26/homebrew--rvm--awesome/

如果这有帮助,ffi-1.0.11 会顺利安装,fff-1.9.0 将不会安装 (http://rubygems.org/gems/ffi/versions)。

/Users/Sam/.rvm/gems/ruby-1.9.3-p448@omega.ecoop/gems/ffi-1.0.11 (no problem)

我想只使用命令行(而不是珠宝盒 GUI)来学习一些新技能,但我还是卡在这里。任何帮助将不胜感激,谢谢。

编辑

所以我尝试了一种不同的方法,我想可能是 ruby​​ 的版本不兼容:

rvm install 2.0.0

然后这次使用 ruby​​ 2.0.0 创建 gemset

rvm use 2.0.0@omega.ecoop --create

检查它的存在并选择为当前 gemset(准备安装一些 gem)

rvm gemset list

gemsets for ruby-2.0.0-p247 (found in /Users/Sam/.rvm/gems/ruby-2.0.0-p247)
(default)
global
=> omega.ecoop

是的,一切都很好。尝试安装

bundle install

Sams-MacBook-Pro:ecoop Sam$ bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Installing addressable (2.3.5) 
Installing chunky_png (1.2.8) 
Installing fssm (0.2.10) 
Installing sass (3.2.10) 
Installing compass (0.12.2) 
Installing breakpoint (2.0.6) 
Installing coderay (1.0.9) 
Installing compass-blend-modes (0.0.2) 
Installing color-schemer (0.2.5) 
Installing compass-normalize (1.4.3) 
Installing compass-rgbapng (0.2.1) 
Installing compass-validator (3.0.1) 
Installing css_parser (1.3.5) 
Installing eventmachine (1.0.3) 
Installing http_parser.rb (0.5.3) 
Installing em-websocket (0.5.0) 
Installing ffi (1.9.0)
Installing formatador (0.2.4) 
Installing rb-fsevent (0.9.3) 
Installing rb-inotify (0.9.1) 
Installing rb-kqueue (0.2.0) 
Installing listen (1.3.0) 
Installing lumberjack (1.0.4) 
Installing method_source (0.8.2) 
Installing slop (3.4.6) 
Installing pry (0.9.12.2) 
Installing thor (0.18.1) 
Installing guard (1.8.2) 
Installing guard-compass (0.0.8) 
Installing multi_json (1.7.9) 
Installing guard-livereload (1.4.0) 
Installing guard-shell (0.5.1) 
Installing oily_png (1.1.0) 
Installing rb-fchange (0.0.6) 
Installing sass-globbing (1.1.0) 
Installing sassy-strings (1.0.0) 
Installing singularitygs (1.1.2) 
Installing susy (1.0.9) 
Installing toolkit (1.3.7) 
Installing yajl-ruby (1.1.0) 
Using bundler (1.3.5) 
Your bundle is complete!

这次“安装 ffi (1.9.0)”没有问题。然后我删除了 ruby​​ 1.9.3,因为我现在只将它用于 compass/sass/susy,如果 2.0.0 有效,那就这样吧。

Sams-MacBook-Pro:~ Sam$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.3.0]
Sams-MacBook-Pro:~ Sam$ cd drupal/ecoop/sites/default/themes/ecoop/
ruby-1.9.3-p448 is not installed.

To install do: 'rvm install ruby-1.9.3-p448' <<<<<< no thanks

Sams-MacBook-Pro:ecoop Sam$ compass watch
>>> Change detected at 12:35:09 to: reset.scss
overwrite css/reset.css 
overwrite css/styles.css 
>>> Compass is watching for changes. Press Ctrl-C to Stop.

现在适用于我的项目。不确定使用较新版本的 ruby​​ 的任何后果,但已经浪费了足够的时间,需要做一些设计。显然,这对需要 1.9.3 的人没有帮助,因此关于为什么 ffi 无法安装的原始问题尚未得到解决。

【问题讨论】:

  • 我在另一台机器上遇到了同样的问题。我的一台机器工作正常,第二台机器的设置方式基本相同。真的只是想坚持使用 1.9.3,因为我正试图将其复制到其他人的机器上。即使尝试仅在其自身上安装 ffi gem 也会导致相同的“无法构建本机扩展”。所有的 xcode 和命令行工具都更新了.. homebrew 更新了,等等。

标签: ruby macos rvm ffi


【解决方案1】:
Sams-MacBook-Pro:~ Sam$ cd drupal/ecoop/sites/default/themes/ecoop/
ruby-1.9.3-p448 is not installed.

To install do: 'rvm install ruby-1.9.3-p448' <<<<<< no thanks

您在该目录中的 .ruby-version 文件仍然是 1.9.3。

【讨论】:

    【解决方案2】:

    我的两分钱——好吧,tuppenny。

    在第 11 步之前运行 bundle install 时,我在尝试 install an Omega 4 subtheme in Drupal 时遇到了这个问题(指南中没有提到......叹息。)

    Omega 有大量名为 {{ THEME }} 的占位符,它们将被您的自定义主题名称替换 - 不知何故(请原谅我,因为我对 Ruby 一无所知!)它试图在 gemfile 中使用这个带有空格的奇怪占位符。

    它还尝试将宝石保存到文件夹 /home/ubuntu/.rvm/gems/ruby-1.9.3-p547@omega.{{ THEME }}/gems,我知道它看起来很糟糕。

    为了解决它,我做了以下操作:

    rvm use 1.9.3-p547@omega.subthemename --create
    rvm gemset list
    
      gemsets for ruby-1.9.3-p547 (found in /home/ubuntu/.rvm/gems/ruby-1.9.3-p547)
         (default)
         global
      => omega.mysubtheme
         omega.{{ THEME }}
    
    bundle install # This now works!
    

    希望这对某人有所帮助!结论是,这通常是某个地方的文件名空间的问题——很多人对 OSX 有问题,因为它解析了“Macintosh HD”的路径,这是一个无效的名称。

    【讨论】:

      【解决方案3】:

      您需要确保已安装 gcc46

      尝试brew install gcc46,然后重新运行bundle install

      【讨论】:

      • 谢谢亚历克斯。我现在正在使用 ruby​​ 2.0.0p247 并且没有尝试返回并安装早期版本,所以我不能说这是否解决了它。
      • 错误:gcc46 没有可用的公式
      • @briggimus 出现同样的错误/错误:gcc46 没有可用的公式
      • 您需要先 brew tap homebrew/versions。
      • 可能在apple-gcc42
      【解决方案4】:

      通常当我遇到此问题时,解决方案是确保 Xcode 已更新。

      【讨论】:

        猜你喜欢
        • 2014-03-01
        • 1970-01-01
        • 1970-01-01
        • 2013-08-27
        • 2019-06-07
        • 2015-07-21
        • 1970-01-01
        • 1970-01-01
        • 2013-11-19
        相关资源
        最近更新 更多