今天在安装一个项目的依赖时,遇到无法安装sassc这个包,经过几个小时的努力,找到了解决法
本人使用的环境是 Ubuntu 20.04.4 LTS (GNU/Linux 5.4.0-117-generic x86_64)
安装依赖包的命令是:
在项目目录下执行
bundle install
其它包都能正常安装,当遇到sassc这个包时报错了
bundle install
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine.
Fetching gem metadata from https://rubygems.org/............
Using concurrent-ruby 1.1.9
Using i18n 1.6.0
Using minitest 5.14.4
Using tzinfo 2.0.4
Using zeitwerk 2.5.1
Using activesupport 6.1.4.1
Using public_suffix 4.0.6
Using addressable 2.8.0
Using execjs 2.7.0
Using autoprefixer-rails 10.2.5.0
Using backports 3.21.0
Using bundler 2.3.17
Using coffee-script-source 1.12.2
Using coffee-script 2.4.1
Using contracts 0.13.0
Using dotenv 2.7.6
Using erubis 2.7.0
Using fast_blank 1.0.1
Using fastimage 2.2.5
Using ffi 1.15.4
Using temple 0.8.2
Using tilt 2.0.10
Using haml 5.2.2
Using hamster 3.0.0
Using hashie 3.6.0
Using rexml 3.2.5
Using kramdown 2.3.1
Using rb-fsevent 0.11.0
Using rb-inotify 0.10.1
Using listen 3.0.8
Using memoist 0.16.2
Using thor 1.1.0
Using middleman-cli 4.4.2
Using padrino-support 0.15.1
Using padrino-helpers 0.15.1
Using parallel 1.21.0
Using rack 2.2.3
Installing sassc 2.4.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
然后单独安装这个包
gem install sassc
也会报错,然后各种百度,百度上的关于sassc安装的资料比较少,然后到国外网站上,终于看到了一种解决办法:
gem install sassc -- --disable-march-tune-native
用这个命令安装依赖包就可以了
我试了一下,就正常了
bundle install
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine.
Fetching gem metadata from https://rubygems.org/............
Using concurrent-ruby 1.1.9
Using i18n 1.6.0
Using minitest 5.14.4
Using tzinfo 2.0.4
Using zeitwerk 2.5.1
Using activesupport 6.1.4.1
Using public_suffix 4.0.6
Using addressable 2.8.0
Using execjs 2.7.0
Using autoprefixer-rails 10.2.5.0
Using backports 3.21.0
Using bundler 2.3.17
Using coffee-script-source 1.12.2
Using coffee-script 2.4.1
Using contracts 0.13.0
Using dotenv 2.7.6
Using erubis 2.7.0
Using fast_blank 1.0.1
Using fastimage 2.2.5
Using ffi 1.15.4
Using temple 0.8.2
Using tilt 2.0.10
Using haml 5.2.2
Using hamster 3.0.0
Using hashie 3.6.0
Using rexml 3.2.5
Using kramdown 2.3.1
Using rb-fsevent 0.11.0
Using rb-inotify 0.10.1
Using listen 3.0.8
Using memoist 0.16.2
Using thor 1.1.0
Using middleman-cli 4.4.2
Using padrino-support 0.15.1
Using padrino-helpers 0.15.1
Using parallel 1.21.0
Using rack 2.2.3
Using sassc 2.4.0
Fetching servolux 0.13.0
Installing servolux 0.13.0
Fetching parslet 2.0.0
Installing parslet 2.0.0
Fetching toml 0.3.0
Installing toml 0.3.0
Fetching uglifier 3.2.0
Installing uglifier 3.2.0
Fetching webrick 1.7.0
Installing webrick 1.7.0
Fetching middleman-core 4.4.2
Installing middleman-core 4.4.2
Fetching middleman 4.4.2
Installing middleman 4.4.2
Fetching middleman-autoprefixer 3.0.0
Installing middleman-autoprefixer 3.0.0
Fetching sprockets 3.7.2
Installing sprockets 3.7.2
Fetching middleman-sprockets 4.1.1
Installing middleman-sprockets 4.1.1
Fetching rouge 3.28.0
Installing rouge 3.28.0
Fetching middleman-syntax 3.2.0
Installing middleman-syntax 3.2.0
Fetching mini_portile2 2.8.0
Installing mini_portile2 2.8.0
Fetching racc 1.6.0
Installing racc 1.6.0 with native extensions
Fetching nokogiri 1.13.4 (x86_64-linux)
Installing nokogiri 1.13.4 (x86_64-linux)
Fetching redcarpet 3.5.1
Installing redcarpet 3.5.1 with native extensions
Using sass-listen 4.0.0
Using sass 3.7.4
Bundle complete! 9 Gemfile dependencies, 56 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
如果有遇到在linux环境中安装sassc无法安装的也可以用此方法试试
此方法的原文在
//stackoverflow.com/questions/66456656/error-installing-sassc-clang-compiler-does-not-support-march-native-m1
//github.com/sass/sassc-ruby/issues/222#issuecomment-857092485