无法构建gem原生扩展(安装Compass)

cus*_*ice 261 ruby macos terminal compass-sass

当我尝试安装最新版本的指南针(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
Run Code Online (Sandbox Code Playgroud)

这里发生了什么?如何安装最新的指南针而不出错?

Rut*_*ren 559

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

apt-get install ruby-dev
Run Code Online (Sandbox Code Playgroud)

  • `xcode-select --install`适用于OSX (52认同)
  • 这修复了Ubuntu上的错误,但似乎OP正在使用OSX. (30认同)
  • 使用"yum install ruby​​-devel"在CentOS上工作,这相当于.谢谢 ! (30认同)
  • 有趣的是在回答OSx问题时找到我的Ubuntu问题的解决方案.尽管如此,你已经得到了我的支持,因为你的答案刚刚解决了我的问题.TNX! (6认同)
  • 这对我来说很有用. (4认同)
  • 知道如何让它在Windows上运行吗?我使用`choco install ruby​​2.devkit`安装了Ruby dev工具,但它仍然无法正常工作 (3认同)
  • 谁能解释为什么这种灵魂奏效? (2认同)
  • 我认为安装 ruby​​-dev 有帮助,但我还必须安装 gcc 和 make。错误对此不是很清楚。 (2认同)

小智 121

为了安装指南针在Mac OS X 10.10(Yosemite)上必须执行以下操作:

1.设置Ruby环境

  • 确保安装ruby并保持最新: ruby -v
  • 更新宝石 sudo gem update --system

2.设置MAC环境

- 安装Xcode命令行工具这是安装Compass的关键. ruby -v

- 安装Xcode命令行工具是让Compass在OS X上运行的关键

3.安装指南针

sudo gem update --system

  • 在我的情况下丢失的Xcode命令行工具!谢谢 (7认同)
  • 这对我来说只有一个补充 - 您必须实际启动XCODE,以便您可以接受许可协议并让它完成设置.可能值得标记你的答案. (5认同)
  • 对我来说,这是正确的答案,它需要Xcode命令行工具 (3认同)
  • 谢谢,为我工作,你是对的,Xcode命令行工具是关键. (2认同)

小智 42

最好的方法是sudo apt-get install ruby-compass安装指南针.


van*_*102 37

你可以尝试使用Debian

sudo apt-get install gcc ruby-dev rubygems compass
Run Code Online (Sandbox Code Playgroud)

对于Fedora,Centos

yum -y install gcc ruby-devel rubygems compass
Run Code Online (Sandbox Code Playgroud)

它对我有用.

  • 我还必须安装`make`. (4认同)
  • `ruby-dev` 做到了 /sf/ask/1439147881/ (3认同)

小智 30

我和你在同一个问题上挣扎了大约3个小时.截至Compass 1.0.alpha19,要求是rvm版本1.9.3.

有几个未收集的帖子,但对我有用的是以下内容:

  1. sudo gem uninstall sass
  2. sudo gem uninstall compass
  3. rvm install ruby-1.9.3-p448
  4. sudo gem install sass --pre
  5. sudo gem install compass --pre

这样做了.希望它也适合你!

  • 谢谢你,非常有帮助.我将第3步更改为`rvm install ruby​​-2.1.2`,因为1.9.3不再更新 (2认同)

Bla*_*rai 24

为了解决这个问题,我必须确保拥有最新版本的Ruby和宝石gem update --system; 然后,我必须确保安装了Xcode和命令行工具:xcode-select --install.

  • `xcode-select --install`为我工作. (6认同)
  • `xcode-select --install` 已完成,但这并不能为我解决 (2认同)

use*_*907 14

在Mac OS上,您需要安装此功能!

xcode-select --install
Run Code Online (Sandbox Code Playgroud)

  • 这不能在macOS Mojave上解决 (2认同)

pau*_*l.g 10

嗨,让它在Mac上工作是一个挑战,所以无论如何这里是一个解决方案

  1. 安装macports
  2. 安装rvm
  3. 重启终端
  4. 运行rvm requirements然后运行rvm install 2.1
  5. 最后一步来运行 gem install compass --pre

我不确定但是Mavericks上的ruby版本不支持本机扩展等...所以如果你指向其他ruby版本,就像我做"2.1"一样,它工作正常.


tbr*_*mer 6

不知道为什么这些都没有被标记为正确的答案,但我通过谷歌搜索登陆这里,所以我将传递我所知道的...

@ paul_g的方法非常接近我,我在Mac OSx10.9 Retina上的步骤:

  • 安装macports
  • 安装rvm(与Ruby --insecure相关问题的ruby add 标志稳定)$\curl -sSL --insecure https://get.rvm.io | bash -s stable --ruby
  • 重启终端/资源您的个人资料
  • 运行rvm requirements --with-gcc=clang您不必更新Ruby,因为您下载了最后一个稳定版本
  • 最后一步来运行 gem install compass --pre


小智 6

sudo gem update --system
sudo gem install compass 
Run Code Online (Sandbox Code Playgroud)


Eri*_*ana 5

对于 Mac 操作系统:

我的错误是我忘记在安装新的 XCode 后在 XCode - 首选项 - 位置 - 命令行工具中选择选项(我有 2 个版本,后来删除了一个)。也许它会对某人有所帮助。

在此输入图像描述


Adr*_*ian 5

如果您使用的是 Ubuntu,您应该尝试安装 build-essential

apt install build-essential
Run Code Online (Sandbox Code Playgroud)

我在全新安装 ubuntu 时遇到了 gems 安装问题,这个解决方案对我有用。