ruby 无法构建 gem 本机扩展(安装指南针)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22544754/
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
Failed to build gem native extension (installing Compass)
提问by cusejuice
When I attempt to install the latest version of compass (https://rubygems.org/gems/compass/versions/1.0.0.alpha.17), I get the following error.
当我尝试安装最新版本的指南针 ( 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
What's going on here? How do I install the latest compass without error?
这里发生了什么?如何安装最新的指南针而不会出错?
回答by Rutger van Baren
Try this, then try to install compass again
试试这个,然后再次尝试安装指南针
apt-get install ruby-dev
回答by neteru
In order to install compass On Mac OS X 10.10 (Yosemite)had to perform the following:
为了在 Mac OS X 10.10 (Yosemite) 上安装指南针,必须执行以下操作:
1. Set Up Ruby Environment
1. 搭建 Ruby 环境
- Ensure ruby is installed and up to date:
ruby -v - Update gem's
sudo gem update --system
- 确保安装了 ruby 并且是最新的:
ruby -v - 更新宝石
sudo gem update --system
2. Set Up MAC Environment
2.设置MAC环境
Install the Xcode Command Line Toolsthis is the key to install Compass.
安装Xcode Command Line Tools这是安装 Compass 的关键。
xcode-select --install
Installing the Xcode Command Line Tools are the key to getting Compass working on OS X
安装 Xcode 命令行工具是让 Compass 在 OS X 上工作的关键
3. Install Compass
3.安装指南针
sudo gem install compass
回答by cooljl31
The best way is sudo apt-get install ruby-compassto install compass.
最好的方法是sudo apt-get install ruby-compass安装指南针。
回答by vanduc1102
You can try in Debian with
你可以在 Debian 中尝试
sudo apt-get install gcc ruby-dev rubygems compass
for Fedora, Centos
用于 Fedora、Centos
yum -y install gcc ruby-devel rubygems compass
It worked for me.
它对我有用。
回答by A. A. Trabucco Campos
I struggled with you same issue for about 3 hours. As of Compass 1.0.alpha19, the requirement is for the rvm version 1.9.3.
我与你同样的问题挣扎了大约 3 个小时。截至Compass 1.0.alpha19,要求是 rvm 版本 1.9.3。
There are several uncollected posts, however what worked for me was the following:
有几个未收集的帖子,但是对我有用的是以下内容:
sudo gem uninstall sasssudo gem uninstall compassrvm install ruby-1.9.3-p448sudo gem install sass --presudo gem install compass --pre
sudo gem uninstall sasssudo gem uninstall compassrvm install ruby-1.9.3-p448sudo gem install sass --presudo gem install compass --pre
and that did it. Hope it works for you as well!
做到了。希望它也适用于您!
回答by BlackHatSamurai
For me to solve this issue, I had to make sure I had the most current version of Ruby and the gems gem update --system; then, I had to make sure that Xcode & the Command Line Tools were installed: xcode-select --install.
为了解决这个问题,我必须确保我拥有最新版本的 Ruby 和 gems gem update --system;然后,我必须确保安装了 Xcode 和命令行工具:xcode-select --install.
回答by user3645907
On Mac OS you need to install this feature!
在 Mac OS 上,您需要安装此功能!
xcode-select --install
回答by paul.g
Hi it was a challenge to get it work on Mac so anyway here is a solution
嗨,让它在 Mac 上工作是一个挑战,所以无论如何这里是一个解决方案
- Install macports
- Install rvm
- Restart Terminal
- Run
rvm requirementsthen runrvm install 2.1 - And last step to run
gem install compass --pre
I'm not sure but ruby version on Mavericks doesn't support native extensions etc... so if you point to other ruby version like I did "2.1" it works fine.
我不确定,但 Mavericks 上的 ruby 版本不支持本机扩展等......所以如果你指向其他 ruby 版本,就像我做的“2.1”一样,它工作正常。
回答by tbremer
Not sure why none of these are marked as the correct answer, but I landed here through a google search, so I will pass along what I know...
不知道为什么这些都没有被标记为正确答案,但我是通过谷歌搜索来到这里的,所以我会传递我所知道的......
@paul_g's method was pretty close for me, my steps on a Mac osx10.9 Retina:
@paul_g 的方法对我来说非常接近,我在 Mac osx10.9 Retina 上的步骤:
- Install macports
- Install rvm (stable with ruby add
--insecureflag for SSL related issues) $\curl -sSL --insecure https://get.rvm.io | bash -s stable --ruby - Restart Terminal / Resource your profile
- Run
rvm requirements --with-gcc=clangYou won't have to update Ruby because you downloaded the last stable version - And last step to run
gem install compass --pre
- 安装macports
- 安装 rvm(稳定与 ruby
--insecure为 SSL 相关问题添加标志)$\curl -sSL --insecure https://get.rvm.io | bash -s stable --ruby - 重新启动终端/资源您的个人资料
- 运行
rvm requirements --with-gcc=clang您不必更新 Ruby,因为您下载的是最新的稳定版本 - 最后一步运行
gem install compass --pre
回答by John Ryan
You could need to install Apple's Command Line Tools, which probably aren't installed on your system by default. I was getting the same error, but before following any of the instructions here I installed Command Line Tools (due to an unrelated issue) and lo and behold compass installed without issue when I tried again. YMMV.
您可能需要安装 Apple 的命令行工具,默认情况下您的系统上可能未安装该工具。我遇到了同样的错误,但在按照此处的任何说明进行操作之前,我安装了命令行工具(由于一个不相关的问题),并且当我再次尝试时,发现指南针安装没有问题。天啊。

