Pocket
LINEで送る

環境:macOS(Majave)

rails勉強すっかぁ〜
gem install rails

・・・・・(インストール中)

ERROR

ファッ!?

もっかい。

gem install rails

ERROR

えええぇぇ〜〜
gem install rails

ERROR!!!!

はい。。。

.....って感じで、なぜかRailsインストールできなかったので、調べてみました。

エラー内容↓(初回インストール時は、一部がインストールされた状態からエラーとなるので下記とは出力が少し違います。)

Building native extensions. This could take a while...

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

current directory: /Users/username/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/nokogiri-1.8.5/ext/nokogiri
/Users/username/.rbenv/versions/2.5.0/bin/ruby -r ./siteconf20181124-37427-16sh9ku.rb extconf.rb

checking if the C compiler accepts ... *** 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=/Users/username/.rbenv/versions/2.5.0/bin/$(RUBY_BASE_NAME)
--help
--clean

/Users/username/.rbenv/versions/2.5.0/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)

You have to install development tools first.
from /Users/username/.rbenv/versions/2.5.0/lib/ruby/2.5.0/mkmf.rb:574:in `block in try_compile'
from /Users/username/.rbenv/versions/2.5.0/lib/ruby/2.5.0/mkmf.rb:521:in `with_werror'
from /Users/username/.rbenv/versions/2.5.0/lib/ruby/2.5.0/mkmf.rb:574:in `try_compile'
from extconf.rb:138:in `nokogiri_try_compile'
from extconf.rb:162:in `block in add_cflags'
from /Users/username/.rbenv/versions/2.5.0/lib/ruby/2.5.0/mkmf.rb:632:in `with_cflags'
from extconf.rb:161:in `add_cflags'
from extconf.rb:410:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:
 /Users/username/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/nokogiri-1.8.5/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/username/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/nokogiri-1.8.5 for inspection.

Results logged to /Users/username/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/nokogiri-1.8.5/gem_make.out

2行目に書いてある通り、nokogiriってやつのインストールに失敗しているみたいですね。

調べてみると、このnokogiriインストールに失敗している人がうじゃうじゃいますね。。。

X-code古いからかな〜と思って、最新版にしてもダメ。Mojaveくんのせいかも?なんでだろう。

とりあえず、私のような初心者はローカルの設定ファイルとかビビって変更してないので、潔く公式HP見てやりました。

公式HP - Nokogiriの鋸

macOS

gem update --system
xcode-select --install # Then agree to the terms, even if you have done this before!

xcode-select --installした時に、network problem出てくるんですが、私は、がん無視してOK押してから再度同じコマンド入力して、流れに沿ってやったらうまくいきました。

公式HPにあるsudo defaults ...はやっていません。

無事に終わったらnokogiriインストールしましょう。

gem install nokogiri

Building native extensions. This could take a while...
Successfully installed nokogiri-1.8.5
Parsing documentation for nokogiri-1.8.5
Installing ri documentation for nokogiri-1.8.5
Done installing documentation for nokogiri after 9 seconds
1 gem installed

やっとうまくいきました!ってか今回は、全然苦労してないんですけど笑。

熟練者だと細々とした設定を行なっているでしょうから、上記だけではうまくいかないこともあるみたいです。。。

これでようやく、Rails入れれます。

gem install rails
スポンサーリンク
おすすめの記事