宝石安装指南针不起作用

时间:2014-11-25 18:21:59

标签: ruby sass zurb-foundation compass

当我尝试使用sudo gem install compass安装指南针时,它会告诉我:

    Building native extensions.  This could take a while...
ERROR:  Error installing compass:
    ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -r ./siteconf20141125-86718-gjziv3-0.rb 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()... no
checking for rb_thread_call_with_gvl()... no
checking for rb_thread_call_without_gvl()... no
checking for ffi_prep_cif_var()... no
creating extconf.h
creating Makefile

make  clean

make
mkdir -p "/Library/Ruby/Gems/1.8/gems/ffi-1.9.6/ext/ffi_c"/libffi-i386; (if [ ! -f "/Library/Ruby/Gems/1.8/gems/ffi-1.9.6/ext/ffi_c"/libffi-i386/Makefile ]; then echo "Configuring libffi for i386"; cd "/Library/Ruby/Gems/1.8/gems/ffi-1.9.6/ext/ffi_c"/libffi-i386 && env CC=" xcrun cc" CFLAGS="-arch i386 " LDFLAGS="-arch i386" "/Library/Ruby/Gems/1.8/gems/ffi-1.9.6/ext/ffi_c/libffi"/configure --disable-static --with-pic=yes --disable-dependency-tracking --host=i386-apple-darwin > /dev/null; fi); env MACOSX_DEPLOYMENT_TARGET=10.4 make -C "/Library/Ruby/Gems/1.8/gems/ffi-1.9.6/ext/ffi_c"/libffi-i386
Configuring libffi for i386
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 `/Library/Ruby/Gems/1.8/gems/ffi-1.9.6/ext/ffi_c/libffi-i386':
configure: error: C compiler cannot create executables
See `config.log' for more details
make[1]: *** No targets specified and no makefile found.  Stop.
make: *** ["/Library/Ruby/Gems/1.8/gems/ffi-1.9.6/ext/ffi_c"/libffi-i386/.libs/libffi_convenience.a] Error 2

make failed, exit code 2

Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/ffi-1.9.6 for inspection.
Results logged to /Library/Ruby/Gems/1.8/extensions/universal-darwin-11/1.8/ffi-1.9.6/gem_make.out

我已经正确安装了sass和xcode'工具,但没有任何改变。我甚至尝试升级ruby。我该怎么办?

1 个答案:

答案 0 :(得分:2)

之所以发生这种情况,是因为你想要sudo安装,可能环境变量没有配置为使用你安装的ruby,而是使用系统ruby,这可能不是你想要使用的。

在Mac上使用Ruby的最简单方法是使用自制软件安装rbenv和ruby-build。

要安装自制软件,只需运行此命令,该命令可在brew homepage上找到:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

要安装rbenv和ruby-build,您可以运行这些命令,这些命令可以在Github上找到:

brew update
brew install rbenv ruby-build

忘记添加它肯定,然后你需要使用rbenv安装ruby版本并使其成为全局。

rbenv install 2.1.5
rbenv global 2.1.5

最后:

gem install compass

只需确保gem二进制文件指向您安装的版本 您可以运行gem env并检查打印路径,如果它没有指向新安装的ruby gem路径,关闭终端并打开一个新路径然后安装gem。

以下是我机器上打印出来的前几行:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.2.0
  - RUBY VERSION: 2.1.0 (2013-12-25 patchlevel 0) [x86_64-darwin13.0]
  - INSTALLATION DIRECTORY: /Users/jani/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
  ....
相关问题