当我试图安装最新版本的compass (https://rubygems.org/gems/compass/versions/1.0.0.alpha.17)时,我得到以下错误。

ERROR:  Error installing compass:
ERROR: Failed to build gem native extension.

 ERROR:  Error installing compass:
  ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... yes
checking for ffi_call() in -lffi... yes
checking for ffi_prep_closure()... yes
checking for ffi_raw_call()... 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 "DESTDIR=" clean

make "DESTDIR="
compiling AbstractMemory.c
compiling ArrayType.c
compiling Buffer.c
compiling Call.c
Call.c:303:5: warning: implicit declaration of function 'rb_thread_call_without_gvl' is invalid in C99 [-Wimplicit-function-declaration]
    rbffi_thread_blocking_region(call_blocking_function, data, (void *) -1, NULL);
    ^
./Thread.h:78:39: note: expanded from macro 'rbffi_thread_blocking_region'
# define rbffi_thread_blocking_region rb_thread_call_without_gvl
                                      ^
1 warning generated.
compiling ClosurePool.c
compiling DataConverter.c
DataConverter.c:43:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 warning generated.
compiling DynamicLibrary.c
compiling ffi.c
compiling Function.c
Function.c:479:33: warning: incompatible pointer types passing 'VALUE (void *)' to parameter of type 'void *(*)(void *)' [-Wincompatible-pointer-types]
        rb_thread_call_with_gvl(callback_with_gvl, &cb);
                                ^~~~~~~~~~~~~~~~~
Function.c:102:46: note: passing argument to parameter 'func' here
extern void *rb_thread_call_with_gvl(void *(*func)(void *), void *data1);
                                             ^
Function.c:563:9: warning: implicit declaration of function 'rb_thread_call_without_gvl' is invalid in C99 [-Wimplicit-function-declaration]
        rb_thread_call_without_gvl(async_cb_wait, &w, async_cb_stop, &w);
        ^
Function.c:738:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
3 warnings generated.
compiling FunctionInfo.c
compiling LastError.c
compiling LongDouble.c
compiling MappedType.c
compiling MemoryPointer.c
compiling MethodHandle.c
compiling Platform.c
compiling Pointer.c
compiling Struct.c
compiling StructByReference.c
compiling StructByValue.c
compiling StructLayout.c
compiling Thread.c
compiling Type.c
compiling Types.c
compiling Variadic.c
linking shared-object ffi_c.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [ffi_c.bundle] Error 1

make failed, exit code 2

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

这是怎么回事?如何正确安装最新的指南针?


当前回答

在Mac OS X 10.9上,如果你尝试xcode-select——install,你会得到以下错误:

无法安装该软件,因为它当前不可用 软件更新服务器。

解决方案是直接从苹果网站https://developer.apple.com/downloads/index.action?name=for%20Xcode%20-下载命令行工具(OS X 10.9)

然后,您将能够安装命令行工具的最新版本。

其他回答

试试这个,然后再试着安装指南针

sudo apt install ruby-full

你可能需要安装苹果的命令行工具,默认情况下可能没有安装在你的系统上。我得到了同样的错误,但在遵循这里的任何说明之前,我安装了命令行工具(由于一个不相关的问题),当我再次尝试时,指南针安装没有问题。YMMV。

尝试brew install coreutils。

我在重建一个老旧的sass/compass项目时遇到了这个问题,这个项目最近被一个同事更新到ruby 2.2.5。本项目使用rvm和bundler。这是我的命令

$ rvm install ruby-2.2.5
$ rvm use ruby-2.2.5
$ gem install bundler
$ bundle install

这导致我遇到了著名的ffi安装错误,这是围绕StackOverflow环境报告的:

An error occurred while installing ffi (1.9.14), and Bundler cannot continue.

大多数解决这个问题的建议是安装Xcode命令行工具。然而,这已经安装在我的环境:

$ xcode-select -p
/Library/Developer/CommandLineTools

其他建议说,安装gcc…所以我试着:

$ brew install gcc46

但这也失败了,因为分割错误…¯\_()_/¯。

所以,我尝试手动安装compass,看看它是否会给出相同的ffi错误:

$ gem install compass

但令我惊讶的是,我得到了一个完全不同的错误:

make: /usr/local/bin/gmkdir: No such file or directory

所以我搜索了这个问题,找到了这篇古老的博客文章,上面说要安装coreutils:

$ brew install coreutils

在使用Homebrew安装coreutils后,bundler能够完成并成功安装compass和依赖项。

最后。

在Mac OS上你需要安装这个功能!

xcode-select --install

在Mac OS X 10.9上,如果你尝试xcode-select——install,你会得到以下错误:

无法安装该软件,因为它当前不可用 软件更新服务器。

解决方案是直接从苹果网站https://developer.apple.com/downloads/index.action?name=for%20Xcode%20-下载命令行工具(OS X 10.9)

然后,您将能够安装命令行工具的最新版本。