ERROR: Error installing sass: ERROR: Failed to build gem native extension
ERROR: Error installing sass: ERROR: Failed to build gem native extension
我正在尝试安装 sass。我确实设法通过 npm 安装它(1.14.1 用 dart2js 2.0.0 编译),但是我需要用 Ruby (Ruby Sass 3.5.6.) 安装它。现在,这是我 运行 "sudo gem install sass"
时的错误
Building native extensions. This could take a while...
ERROR: Error installing sass:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.9.25/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20181004-3909-1iytz3s.rb extconf.rb
checking for ffi.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/$(RUBY_BASE_NAME)
--with-ffi_c-dir
--without-ffi_c-dir
--with-ffi_c-include
--without-ffi_c-include=${ffi_c-dir}/include
--with-ffi_c-lib
--without-ffi_c-lib=${ffi_c-dir}/lib
--with-libffi-config
--without-libffi-config
--with-pkg-config
--without-pkg-config
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:456:in 'try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:571:in `block in try_compile'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:524:in `with_werror'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:571:in `try_compile'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:1091:in `block in have_header'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:942:in `block in checking_for'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:320:in `open'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:350:in `block in postpone'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:320:in `open'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:346:in `postpone'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:941:in `checking_for'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:1090:in `have_header'
from extconf.rb:16:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.9.25/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/ffi-1.9.25 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.9.25/gem_make.out
我尝试更新 Ruby,删除通过 npm 安装的 sass,按照某些建议更新 xcode 开发工具。但没有任何效果。我不知道是什么原因,因为在从 0.
更新到新的 Mac OS Mojave 之前我有 sass
这是 mkmf.log 文件:
package configuration for libffi is not found
"xcrun clang -o conftest -
I/System/Library/Frameworks/Ruby.framework
/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin18 -
I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/
include/ruby-2.3.0/ruby/backward -
I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/
ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -
D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -
DHAVE_GCC_ATOMIC_BUILTINS conftest.c -L. -
L/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib -L.
-lruby.2.3.0 -lpthread -ldl -lobjc "
In file included from conftest.c:1:
In file included from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/
ruby-2.3.0/ruby.h:33:
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/
ruby-2.3.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found
#include "ruby/config.h"
^~~~~~~~~~~~~~~
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
有什么想法吗?
好的,所以找到了解决方案。如果你有这个错误。这样做:
安装 rvm (https://rvm.io/)
然后我不得不运行这个命令来让 rvm 工作:
if sudo grep -q secure_path /etc/sudoers;然后 sudo sh -c "echo export rvmsudo_secure_path=1 >> /etc/profile.d/rvm_secure_path.sh" && echo 安装环境变量; fi
- 接下来我删除了 rvm ruby:
rvm 删除 ruby
- 最后安装 ruby:
rvm 安装ruby
不确定是否需要这一步,但这是我在控制台中看到的:Ruby 构建时没有文档,要构建它 运行:rvm docs generate -ri
所以我也运行这个命令。在那之后我终于能够 sudo gem install sass.
现在可以使用了!
执行 mac 中的以下步骤以无错误安装 SASS
- 安装 gpg
brew install -v gpg
- 安装 gpg 密钥
gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
- 允许 curl 到 运行 而不检查 SSL(否则命令 #4 将抛出错误)
echo 不安全 >> ~/.curlrc
- 安装rvm
\curl -sSL -k https://get.rvm.io | bash
- 要使用 rvm,您将在 #3 中的 运行ning 命令后得到如下输出:
要开始使用 RVM,您需要 运行
source /Users/ymehta/.rvm/scripts/rvm
复制粘贴命令并按 Enter
- 删除现有的 ruby 版本
rvm 删除 ruby
- 安装ruby
rvm 安装 ruby
- rvm 文档生成-ri
- 安装sass
须藤宝石安装 sass
- 检查sass版本
sass --版本
可以在 https://gist.github.com/Yashvi-Mehta/9ad81330d1703f12a00b63cf20c9cdb3
找到相同的步骤
我正在尝试安装 sass。我确实设法通过 npm 安装它(1.14.1 用 dart2js 2.0.0 编译),但是我需要用 Ruby (Ruby Sass 3.5.6.) 安装它。现在,这是我 运行 "sudo gem install sass"
时的错误Building native extensions. This could take a while...
ERROR: Error installing sass:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.9.25/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20181004-3909-1iytz3s.rb extconf.rb
checking for ffi.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/$(RUBY_BASE_NAME)
--with-ffi_c-dir
--without-ffi_c-dir
--with-ffi_c-include
--without-ffi_c-include=${ffi_c-dir}/include
--with-ffi_c-lib
--without-ffi_c-lib=${ffi_c-dir}/lib
--with-libffi-config
--without-libffi-config
--with-pkg-config
--without-pkg-config
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:456:in 'try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:571:in `block in try_compile'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:524:in `with_werror'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:571:in `try_compile'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:1091:in `block in have_header'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:942:in `block in checking_for'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:320:in `open'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:350:in `block in postpone'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:320:in `open'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:346:in `postpone'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:941:in `checking_for'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:1090:in `have_header'
from extconf.rb:16:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.9.25/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/ffi-1.9.25 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.9.25/gem_make.out
我尝试更新 Ruby,删除通过 npm 安装的 sass,按照某些建议更新 xcode 开发工具。但没有任何效果。我不知道是什么原因,因为在从 0.
更新到新的 Mac OS Mojave 之前我有 sass这是 mkmf.log 文件:
package configuration for libffi is not found
"xcrun clang -o conftest -
I/System/Library/Frameworks/Ruby.framework
/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin18 -
I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/
include/ruby-2.3.0/ruby/backward -
I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/
ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -
D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -
DHAVE_GCC_ATOMIC_BUILTINS conftest.c -L. -
L/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib -L.
-lruby.2.3.0 -lpthread -ldl -lobjc "
In file included from conftest.c:1:
In file included from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/
ruby-2.3.0/ruby.h:33:
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/
ruby-2.3.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found
#include "ruby/config.h"
^~~~~~~~~~~~~~~
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
有什么想法吗?
好的,所以找到了解决方案。如果你有这个错误。这样做:
安装 rvm (https://rvm.io/)
然后我不得不运行这个命令来让 rvm 工作:
if sudo grep -q secure_path /etc/sudoers;然后 sudo sh -c "echo export rvmsudo_secure_path=1 >> /etc/profile.d/rvm_secure_path.sh" && echo 安装环境变量; fi
- 接下来我删除了 rvm ruby:
rvm 删除 ruby
- 最后安装 ruby:
rvm 安装ruby
不确定是否需要这一步,但这是我在控制台中看到的:Ruby 构建时没有文档,要构建它 运行:rvm docs generate -ri
所以我也运行这个命令。在那之后我终于能够 sudo gem install sass.
现在可以使用了!
执行 mac 中的以下步骤以无错误安装 SASS
- 安装 gpg brew install -v gpg
- 安装 gpg 密钥 gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
- 允许 curl 到 运行 而不检查 SSL(否则命令 #4 将抛出错误) echo 不安全 >> ~/.curlrc
- 安装rvm \curl -sSL -k https://get.rvm.io | bash
- 要使用 rvm,您将在 #3 中的 运行ning 命令后得到如下输出:
要开始使用 RVM,您需要 运行
source /Users/ymehta/.rvm/scripts/rvm
复制粘贴命令并按 Enter - 删除现有的 ruby 版本 rvm 删除 ruby
- 安装ruby rvm 安装 ruby
- rvm 文档生成-ri
- 安装sass 须藤宝石安装 sass
- 检查sass版本 sass --版本
可以在 https://gist.github.com/Yashvi-Mehta/9ad81330d1703f12a00b63cf20c9cdb3
找到相同的步骤