首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >错误:安装sass时出错:错误:无法生成gem本机扩展

错误:安装sass时出错:错误:无法生成gem本机扩展
EN

Stack Overflow用户
提问于 2018-10-04 18:21:29
回答 2查看 5.2K关注 0票数 1

我在试着安装sass。我确实通过npm (用dart2js 2.0.0编译的1.14.1)安装了它,但是我需要用Ruby3.5.6安装它。现在,下面是我运行"sudo gem install sass“时的错误。

代码语言:javascript
运行
复制
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开发工具。但什么都不管用。我不知道原因是什么,因为在升级到新的Mojave之前,我已经从0开始使用sass了。

下面是mkmf.log文件:

代码语言:javascript
运行
复制
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 */

有什么想法吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-10-04 21:23:10

好的,所以找到了解决办法。如果你有这个错误。这样做:

  1. 安装rvm (https://rvm.io/)
  2. 然后,为了使rvm工作,我不得不运行这个命令:

如果sudo grep -q secure_path /etc/sudoers;那么sudo sh -c“回声导出rvmsudo_secure_path=1 >> /etc/profile.d/rvm_secure_path.sh.sh”& Environment变量已安装;

  1. 接下来,使用rvm,我删除了ruby:

rvm移除红宝石

  1. 最后安装红宝石:

rvm安装ruby

  1. 不确定是否需要这一步,但这是我在控制台中得到的: Ruby是在没有文档的情况下构建的,要构建它,运行: rvm文档生成-ri。 所以我也运行了这个命令。在那之后,我终于可以做宝石安装sass了。

现在起作用了!

票数 2
EN

Stack Overflow用户

发布于 2021-03-31 09:20:16

在mac中执行以下步骤来安装SASS错误

  1. 安装gpg brew安装-v gpg
  2. 安装gpg键gpg2 --recv-键409B6B1796C275462A1703113804BB82D390E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
  3. 允许curl运行而不检查SSL (否则命令#4将引发错误)回显不安全的>> ~/..curlrc
  4. 安装rvm \curl -sSL -k https://get.rvm.io _ bash
  5. 要使用rvm,您将在运行#3中的命令后获得一个输出,例如:要开始使用RVM,需要运行source /Users/ymehta/.rvm/scripts/rvm复制粘贴命令并按回车
  6. 删除现有的ruby版本rvm删除ruby
  7. 安装ruby安装ruby
  8. rvm文档生成-ri
  9. 安装sass sudo宝石安装sass
  10. 检查sass版本

https://gist.github.com/Yashvi-Mehta/9ad81330d1703f12a00b63cf20c9cdb3中可以找到相同的步骤

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52653198

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档