[英]Failed to build gem native extension (installing 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
这里发生了什么? 如何正确安装最新的指南针?
试试这个,然后再次尝试安装指南针
apt-get install ruby-dev
为了在 Mac OS X 10.10 (Yosemite) 上安装指南针,必须执行以下操作:
1. 搭建 Ruby 环境
ruby -v
sudo gem update --system
2.设置MAC环境
安装Xcode Command Line Tools这是安装 Compass 的关键。
xcode-select --install
安装 Xcode 命令行工具是让 Compass 在 OS X 上工作的关键
3.安装指南针
sudo gem install compass
最好的方法是sudo apt-get install ruby-compass
来安装指南针。
你可以在 Debian 中尝试
sudo apt-get install gcc ruby-dev rubygems compass
用于 Fedora、Centos
yum -y install gcc ruby-devel rubygems compass
它对我有用。
我与你同样的问题挣扎了大约 3 个小时。 从Compass 1.0.alpha19
,要求是 rvm 版本 1.9.3。
有几个未收集的帖子,但是对我有用的是以下内容:
sudo gem uninstall sass
sudo gem uninstall compass
rvm install ruby-1.9.3-p448
sudo gem install sass --pre
sudo gem install compass --pre
做到了。 希望它也适用于您!
为了解决这个问题,我必须确保我拥有最新版本的 Ruby 和 gems gem update --system
; 然后,我必须确保安装了 Xcode 和命令行工具: xcode-select --install
。
在 Mac OS 上,您需要安装此功能!
xcode-select --install
不知道为什么这些都没有被标记为正确答案,但我是通过谷歌搜索来到这里的,所以我会传递我所知道的......
@paul_g 的方法对我来说非常接近,我在 Mac osx10.9 Retina 上的步骤:
--insecure
标志) $ \\curl -sSL --insecure https://get.rvm.io | bash -s stable --ruby
\\curl -sSL --insecure https://get.rvm.io | bash -s stable --ruby
rvm requirements --with-gcc=clang
你不必更新 Ruby 因为你下载了最后一个稳定版本gem install compass --pre
如果您使用的是 Ubuntu,您应该尝试安装 build-essential
apt install build-essential
我在全新安装 ubuntu 时遇到了 gems 安装问题,这个解决方案对我有用。
您可能需要安装 Apple 的命令行工具,默认情况下您的系统上可能未安装该工具。 我遇到了同样的错误,但在按照此处的任何说明进行操作之前,我安装了命令行工具(由于一个不相关的问题),并且当我再次尝试时,发现指南针安装没有问题。 天啊。
为了在 Yosemite 上安装 Compass,您需要设置 Ruby 环境并安装 Xcode 命令行工具。 但是,最重要的是,在更新 Xcode 后,请务必启动 Xcode 应用程序并接受 Apple 许可条款。 它将完成组件的安装。 之后,您可以安装指南针: sudo gem install compass
对于 macOS 10.14 Mojave,请确保您已经通过xcode-select --install
安装了命令行工具,并运行以下命令来安装 std 头文件。
sudo open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
现在再次尝试您的命令。
sudo gem update --system
sudo gem install compass
你必须有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 ** 不工作,您在更新中遇到错误,然后使用
须藤宝石更新 --system 2.7.8
在优胜美地,您必须做的就是安装命令行工具。 那么它的工作原理。
即使其他 gems 安装得很好。 您必须运行 xcode-select --install 才能让 gem install compass 工作。
祝你好运。
在 Mac OS X 10.9 上,如果您尝试xcode-select --install
,您将收到以下错误:
无法安装该软件,因为软件更新服务器当前不提供该软件。
解决方案是直接从 Apple 网站下载命令行工具 (OS X 10.9): https : //developer.apple.com/downloads/index.action?name=for%20Xcode%20-
然后,您将能够安装最新版本的命令行工具。
在 ubuntu 14.04 中,执行apt-get install rubygems时出现错误
E: 包 'rubygems' 没有安装候选
按照命令解决问题。
sudo apt-get install gcc ruby-devel rubygems-integration ruby-compass
尝试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
但这也由于分段错误而失败...... ¯\\_(ツ)_/¯
。
所以,我然后尝试手动安装指南针,只是为了看看它是否会给出相同的ffi
错误:
$ gem install compass
但令我惊讶的是,我得到了一个完全不同的错误:
make: /usr/local/bin/gmkdir: No such file or directory
所以我搜索了这个问题,并找到了这篇古老的博客文章,上面写着要安装 coreutils:
$ brew install coreutils
使用 Homebrew 安装coreutils
后,bundler 能够成功完成并安装指南针和依赖项。
结束。
什么时候
gem安装过量使用
运行此错误也已放置在终端中。
Failed to build gem native extension
请做同样的事情
xcode-select --install
它也会解决这个问题
试试这个,然后再次尝试安装指南针
sudo apt install ruby-full
我在 Linux Mint 上遇到了同样的问题,但我能够通过卸载 ruby 并重新安装来修复它。
卸载红宝石:
sudo apt-get remove ruby
它报告了一些 ruby 包,例如:
Package 'ruby' is not installed, so not removed
The following packages were automatically installed and are no longer required:
libruby2.2 ruby-chunky-png ruby-sass rubygems-integration
Use 'apt-get autoremove' to remove them.
卸载剩余的软件包*
apt-get autoremove
再次安装红宝石
sudo apt-get install ruby2.2
安装指南针
sudo gem install compass
最后一条命令执行成功。
在 Mac 上安装 Ruby gems 是一个常见的困惑和挫折来源。 不幸的是,大多数解决方案都不完整、过时并且提供了糟糕的建议。 此处得票最多的答案是使用sudo
,您永远不需要这样做,尤其是当您不了解它的作用时。
错误“Failed to build gem native extension”是由于没有安装Apple命令行工具是正确的。 但是,安装它们不一定会为您提供合适的 Ruby 环境。 安装 Ruby 需要 5 个步骤,我在我在 Mac 上安装 Ruby gems 的权威指南中详细介绍了这些步骤。 它解释了为什么会出现此错误,比较了各种解决方案,为什么有些解决方案比其他解决方案更好,以及为什么不应该使用sudo
。
TL;DR:使用经过实战测试且可靠的自动化脚本,为您设置一切: https : //github.com/monfresh/laptop
首先必须从 Ruby 2.6 升级到 3.0(参见https://rvm.io/ ):
$ curl -sSL https://get.rvm.io | bash -s stable --ruby
$ source /Usrs/myuser/.rvm/scripts/rvm
然后我不得不在本地安装它,否则 Mac OSX 权限不允许我升级它(请参阅错误:执行 gem 时... (Errno::EPERM) 不允许操作):
$ sudo gem install -n /usr/local/bin compass
我不确定是否需要先安装上面的rvm
,但它对升级 ruby 很有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.