构建本地扩展宝石失败(安装Compass)

302
当我尝试安装最新版本的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

"

这里发生了什么?如何安装最新版的Compass而不出现错误?

"

请确保您的系统上安装了make。 - Sorter
26个回答

6
sudo gem update --system
sudo gem install compass 

5

针对Mac OS系统:

我的错误在于我忘记在新安装XCode后选择选项:XCode - 首选项 - 位置 - 命令行工具(我之前有2个版本,后来删除了一个)。也许这会帮助其他人。

enter image description here


4

您可能需要安装苹果的命令行工具,这些工具可能不会默认安装在您的系统上。我之前也遇到同样的错误,但在按照这里的任何指示之前,我因为另一个无关的问题而安装了命令行工具,当我再次尝试时,发现 Compass 已经顺利安装了。结果可能因人而异。


这对我解决了上述问题,所以我认为这是对上述问题的一个可接受的答案。 - Peter J Harrison

4

要在Yosemite上安装Compass,您需要设置Ruby环境并安装Xcode命令行工具。但是,最重要的是,在更新Xcode之后,一定要启动Xcode应用程序并接受苹果许可条款。这将完成组件的安装。之后,您可以安装Compass:sudo gem install compass。


4

如果您使用的是 macOS 10.14 Mojave,请确保您已经通过xcode-select --install命令安装了命令行工具,并运行以下命令安装std headers。

sudo open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

现在请再次尝试您的命令。


3

你必须要安装gcc和json_pure

我从几篇文章中收集了一些信息

sudo gem uninstall sass
sudo gem uninstall compass
sudo gem update --system
gem install json_pure   (if you have already have continued to next step)
sudo yum install gcc gcc-c++   (if you have already have continued to next step)
sudo gem install sass

sudo gem install compass

如果 ** sudo gem update --system ** 无法正常工作并且更新时出错,则需要使用以下命令:

sudo gem update --system 2.7.8


在安装compass之前,由于出现了这个错误:“gcc: error: /usr/lib/rpm/redhat/redhat-hardened-cc1: No such file or directory”,我还需要在Fedora 24上运行“sudo yum install -y redhat-rpm-config”。 - Bryce Guinta
执行 sudo gem update --system 命令时出现错误:ERROR: While executing gem ... (Errno::EPERM) Operation not permitted @ rb_sysopen - System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/gem :( - Ade

2
在ubuntu 14.04中,当执行apt-get install rubygems时,会出现错误:

E:软件包'rubygems'没有安装候选

执行以下命令可以解决问题:

sudo apt-get install gcc ruby-devel rubygems-integration ruby-compass


2
在Mac OS X 10.9上,如果你尝试运行命令xcode-select --install,你会得到以下错误信息:

无法安装软件,因为当前不能从软件更新服务器中获取。

解决方法是直接从苹果网站下载Command Line Tools(OS X 10.9):https://developer.apple.com/downloads/index.action?name=for%20Xcode%20- 然后你就可以安装最新版本的Command Line Tools了。

2
在yosemite上,您需要安装命令行工具,然后它就能正常工作了。即使其他的gem安装没问题,您也必须运行xcode-select --install才能让gem install compass正常工作。祝好运。

2

当运行 gem install overcommit 命令时,终端会显示以下错误信息。

Failed to build gem native extension

请做相同的事情。
xcode-select --install

并且它也将解决那个问题。


1
我收到了 xcode-select: error: command line tools are already installed, use "Software Update" to install updates 的错误信息。但这并不能解决问题。 - Ade

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接