新版 Mac M2 安装老 saas 项目 报 Gem sass is not installed 问题解决

 

换了新电脑,需要把老项目 git 拉下来再跑起来的时候发现生成样式文件的时候会报这个错误 ,(N年前老项目,用的是 node-sass, gulp-ruby-sass@2.1.1 版本比较老旧,但项目还是要跑,工作还是要做呀)

Error in plugin 'gulp-ruby-sass'
Message:
    Gem sass is not installed.

  于是百度一下,说要让安装 gem sass 

$ gem sources --remove https: //rubygems.org/
$ gem sources --add https://ruby.taobao.org/

$ gem sources -l
*** CURRENT SOURCES ***
https://ruby.taobao.org
然后运行:
$ sudo gem install sass

  结果 淘宝源不给力,已经 404了,只能想使用原始源了

但在安装 gem install sass 的时候一直报这个错:

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.

  还有一些其它错误,但上面这句是关键,根据提示进入到这个路径 

Library/Ruby/Gems/2.6.0/extensions/universal-darwin-21/2.6.0/ffi-1.15.5

查看log 

cat mkmf.log
下面是显示内容
package configuration for libffi is not found

"xcrun clang -o conftest -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin21 -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/backward -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS -DUSE_FFI_CLOSURE_ALLOC conftest.c  -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib -L. -L/AppleInternal/Library/BuildRoots/20d6c351-ee94-11ec-bcaf-7247572f23b4/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.5.Internal.sdk/usr/local/lib     -lruby.2.6   "

In file included from conftest.c:1:

In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby.h:33:

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found

#include "ruby/config.h"

         ^~~~~~~~~~~~~~~

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: note: did not find header 'config.h' in framework 'ruby' (loaded from '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks')

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 */

  上面日志红色部分很关键,这个目录下的这个包在电脑中居然没有此版本,本地的文件夹是 universal-darwin22 ,然后我打开以前可以使用的Mac本的同样的地址文件夹里的版本是 21 ,于是把21版本文件夹考到新 Mac 本的相同路径里,再次运行

sudo gem install sass
下面是提示:

Ruby Sass has reached end-of-life and should no longer be used.

* If you use Sass as a command-line tool, we recommend using Dart Sass, the new
primary implementation: https://sass-lang.com/install

* If you use Sass as a plug-in for a Ruby web framework, we recommend using the
sassc gem: https://github.com/sass/sassc-ruby#readme

* For more details, please refer to the Sass blog:
https://sass-lang.com/blog/posts/7828841

Successfully installed sass-3.7.4
Parsing documentation for sass-3.7.4
Done installing documentation for sass after 1 seconds
1 gem installed

  非常完美!再次启动项目,试着编译一次 css , ok 了!

再次强调一下,安装项目报错不要紧,但一定要看报错日志,一定要看报错日志,一定要看报错日志,重要的事情说三次。

 

 

posted @ 2023-02-24 17:49  久依  阅读(276)  评论(0编辑  收藏  举报