質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.49%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Q&A

解決済

1回答

869閲覧

macOsにScssをRubygemでインストールできない

hokosugi

総合スコア63

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

0グッド

0クリップ

投稿2020/12/04 02:17

macOsにscssをインストールしたいが出来ない。
コマンドで打ち込んだのか下記のリンクを参考して以下の通りです。
MacOS SierraでSassがインストール出来ない時の解決策
MacOS Sierraでsassとcompassをインストールできない

コマンドから

sudo gem install sass -n /usr/local/bin/

で下記のエラー

ERROR: Error installing sass: ERROR: Failed to build gem native extension.

そこで

$xcode-select --install $sudo gcc --version

を試しましたが、

xcode-select: error: command line tools are already installed, use "Software Update" to install updates
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/c++/4.2.1 Apple clang version 12.0.0 (clang-1200.0.32.27) Target: x86_64-apple-darwin19.6.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

と帰ってきてxcodeはインストール済み、gccも古いバージョンではなさそうです(このコマンドを打ち込む意味は理解していない)
再度

sudo gem install sass -n /usr/local/bin/

としても上記と同じエラーが帰ってきます。
どうすればよいのでしょうか?

###試したこと
gemのアップデート

sudo gem update --system -n /usr/local/bin

コマンドラインツールの再インストール

sudo rm -rf /Library/Developer/CommandLineTools xcode-select --install sudo xcodebuild -license accept

どれも変化なしです。

macOs: Catalina 10.15.7
gem: 3.1.4
ruby: 2.6.3p62

下記にエラー全文を挙げていきます。宜しくおねがいします。
###エラー全文

ERROR: Error installing sass: ERROR: Failed to build gem native extension. current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/ext/ffi_c /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf20201204-12991-18pc3ev.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.6/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 --enable-system-libffi --disable-system-libffi --with-libffi-config --without-libffi-config --with-pkg-config --without-pkg-config /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467: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.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in `block in try_compile' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:534:in `with_werror' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in `try_compile' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1109:in `block in have_header' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:959:in `block in checking_for' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block (2 levels) in postpone' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block in postpone' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:357:in `postpone' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:958:in `checking_for' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1108:in `have_header' from extconf.rb:10:in `system_libffi_usable?' from extconf.rb:42:in `<main>' To see why this extension failed to compile, please check the mkmf.log which can be found here: /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/ffi-1.13.1/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1 for inspection. Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/ffi-1.13.1/gem_make.out

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

checking for ffi.h... *** extconf.rb failed ***
from extconf.rb:10:in `system_libffi_usable?'

ffi関連のエラーでsassがコンパイルできないように思われます。
ffi関連のライブラリをインストールしてみて下さい。
homebrewを導入しているならlibffiです

ちなみにrbenvでruby環境を構築すると、すべて自分のホームディレクトリにインストールされます。
管理がしやすいのでお勧めします。

$ type ruby gem sass scss
ruby is /Users/ユーザ名/.rbenv/shims/ruby
gem is /Users/ユーザ名/.rbenv/shims/gem
sass is /Users/ユーザ名/.rbenv/shims/sass
scss is /Users/ユーザ名/.rbenv/shims/scss

投稿2020/12/06 02:41

編集2020/12/06 02:45
technocore

総合スコア7200

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

hokosugi

2020/12/06 10:54

ご回答ありがとうございます。 ご回答のlibffiをインストールしても同じエラーとなり、上手く行かないようなので、ご推奨のrbenvでruby環境を構築してsaccを無事インストール出来ました。 なぜなのか非常に気になるところですが、先を急がないといけないので一旦保留します。 ご回答ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.49%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問