安装 sassc 时出错,clang 编译器不支持 '-march=native',M1
Error installing sassc, clang compiler does not support '-march=native', M1
使用 Apple Silicon M1 机器。正在尝试安装 ruby gem gem install sassc -v '2.1.0'
.
问题是 clang 编译器还没有针对 Apple M1 的标志 'native'。
给出错误:(注意我用 'yournamehere' 替换了我的名字)
Fetching sassc 2.1.0
Installing sassc 2.1.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/sassc-2.1.0/ext
/Users/yournamehere/.asdf/installs/ruby/2.7.2/bin/ruby -I /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0 -r ./siteconf20210303-14183-1uwhwj4.rb extconf.rb
creating Makefile
current directory: /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/sassc-2.1.0/ext
make "DESTDIR=" clean
current directory: /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/sassc-2.1.0/ext
make "DESTDIR="
compiling ./libsass/src/units.cpp
clang: error: the clang compiler does not support '-march=native'
make: *** [units.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/sassc-2.1.0 for inspection.
Results logged to /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/extensions/arm64-darwin-20/2.7.0/sassc-2.1.0/gem_make.out
An error occurred while installing sassc (2.1.0), and Bundler cannot continue.
Make sure that `gem install sassc -v '2.1.0' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
sassc-rails was resolved to 2.1.2, which depends on
sassc
我们可以在没有该标志的情况下手动安装 gem。首先找到 gem 潜伏的位置,看完整的错误这是我们想要的行:
Gem files will remain installed in /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/sassc-2.1.0 for inspection.
所以让我们在终端中导航到那里。在我们 cd
离开该文件夹之前,我们将 运行 未来的命令。
cd /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/sassc-2.1.0
使用 ripgrep 或其他工具在目录中搜索 march=native
。正如完整的错误消息所说,它在 ext/Makefile
中。在这个特定的 Makefile 中,有两个地方有一行 march=native
.
87 CFLAGS = $(CCDLFLAGS) $(cflags) -fno-common -pipe -march=native -mtune=native -flto -DLIBSASS_VERSION='"3.6.1"' $(ARCH_FLAG)
...
91 CXXFLAGS = $(CCDLFLAGS) -g -O2 -std=c++11 -march=native -mtune=native -flto -DLIBSASS_VERSION='"3.6.1"' $(ARCH_FLAG)
Trim 远离所有行的 march=native
。保存并关闭文件。现在我们要构建 gem.
gem build sassc.gemspec
这将创建 sassc-2.1.0.gem
。不要尝试从这里安装它,这个目录会被覆盖。让我们将它复制到下载文件夹(或某个地方)。
mkdir ~/Downloads/sassc
cp -r . ~/Downloads/sassc
现在导航回您在安装 sassc 时遇到问题的起始文件夹。
cd ~/work/projecty_mc_project_face
现在从本地安装,march=native
免费 gem
gem install --local ~/Downloads/sassc/sassc-2.1.0.gem
它应该可以工作
> gem install --local ~/Downloads/sassc/sassc-2.1.0.gem
Building native extensions. This could take a while...
Successfully installed sassc-2.1.0
Parsing documentation for sassc-2.1.0
Installing ri documentation for sassc-2.1.0
Done installing documentation for sassc after 0 seconds
1 gem installed
更新:虽然上述方法允许您捆绑安装,但任何实际使用 sassc 的代码都会引发错误:
LoadError:
cannot load such file -- sassc
这为我解决了:
bundle update sassc
根据 sassc-ruby 上的 this answer,此标志作为当前解决方法对我有用:
gem install sassc -- --disable-march-tune-native
使用 Apple Silicon M1 机器。正在尝试安装 ruby gem gem install sassc -v '2.1.0'
.
问题是 clang 编译器还没有针对 Apple M1 的标志 'native'。
给出错误:(注意我用 'yournamehere' 替换了我的名字)
Fetching sassc 2.1.0
Installing sassc 2.1.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/sassc-2.1.0/ext
/Users/yournamehere/.asdf/installs/ruby/2.7.2/bin/ruby -I /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0 -r ./siteconf20210303-14183-1uwhwj4.rb extconf.rb
creating Makefile
current directory: /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/sassc-2.1.0/ext
make "DESTDIR=" clean
current directory: /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/sassc-2.1.0/ext
make "DESTDIR="
compiling ./libsass/src/units.cpp
clang: error: the clang compiler does not support '-march=native'
make: *** [units.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/sassc-2.1.0 for inspection.
Results logged to /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/extensions/arm64-darwin-20/2.7.0/sassc-2.1.0/gem_make.out
An error occurred while installing sassc (2.1.0), and Bundler cannot continue.
Make sure that `gem install sassc -v '2.1.0' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
sassc-rails was resolved to 2.1.2, which depends on
sassc
我们可以在没有该标志的情况下手动安装 gem。首先找到 gem 潜伏的位置,看完整的错误这是我们想要的行:
Gem files will remain installed in /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/sassc-2.1.0 for inspection.
所以让我们在终端中导航到那里。在我们 cd
离开该文件夹之前,我们将 运行 未来的命令。
cd /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/sassc-2.1.0
使用 ripgrep 或其他工具在目录中搜索 march=native
。正如完整的错误消息所说,它在 ext/Makefile
中。在这个特定的 Makefile 中,有两个地方有一行 march=native
.
87 CFLAGS = $(CCDLFLAGS) $(cflags) -fno-common -pipe -march=native -mtune=native -flto -DLIBSASS_VERSION='"3.6.1"' $(ARCH_FLAG)
...
91 CXXFLAGS = $(CCDLFLAGS) -g -O2 -std=c++11 -march=native -mtune=native -flto -DLIBSASS_VERSION='"3.6.1"' $(ARCH_FLAG)
Trim 远离所有行的 march=native
。保存并关闭文件。现在我们要构建 gem.
gem build sassc.gemspec
这将创建 sassc-2.1.0.gem
。不要尝试从这里安装它,这个目录会被覆盖。让我们将它复制到下载文件夹(或某个地方)。
mkdir ~/Downloads/sassc
cp -r . ~/Downloads/sassc
现在导航回您在安装 sassc 时遇到问题的起始文件夹。
cd ~/work/projecty_mc_project_face
现在从本地安装,march=native
免费 gem
gem install --local ~/Downloads/sassc/sassc-2.1.0.gem
它应该可以工作
> gem install --local ~/Downloads/sassc/sassc-2.1.0.gem
Building native extensions. This could take a while...
Successfully installed sassc-2.1.0
Parsing documentation for sassc-2.1.0
Installing ri documentation for sassc-2.1.0
Done installing documentation for sassc after 0 seconds
1 gem installed
更新:虽然上述方法允许您捆绑安装,但任何实际使用 sassc 的代码都会引发错误:
LoadError:
cannot load such file -- sassc
这为我解决了:
bundle update sassc
根据 sassc-ruby 上的 this answer,此标志作为当前解决方法对我有用:
gem install sassc -- --disable-march-tune-native