LoginSignup
19
10

More than 5 years have passed since last update.

bundle installでmysql2のgemがインストールできなかった時に試したこと

Last updated at Posted at 2018-03-30

環境

macOS High Sierra
Ryby 2.3
Rails 4.2.1

現象

bundle install実行時にmysql2のgemインストールでコケた。

Fetching mysql2 0.4.9
Installing mysql2 0.4.9 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

かなしい。

試したこと

エラーログに書かれているコマンドを実行

An error occurred while installing mysql2 (0.4.9), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.4.9'` succeeds before bundling.

まずはエラーログに書かれているコマンドを実行。

$ gem install mysql2 -v '0.4.9'

コマンドは通るものの、bundle install実行時の状況は変わらず。

Xcodeを最新にアップデート

Xcodeを最新にアップデートすると解決することが多いとのことでやってみる。
Xcodeが入っていない環境だったのでApp Store経由で最新版をインストール。

念のためコマンドラインツールも確認。

$ xcode-select --install

状況変わらず。

mysqlをインストール

ログの上の方を見てみると

mysql client is missing. You may need to 'brew install mysql' or 'port install mysql', and
try again.

と書かれていた。

そもそもこの環境にmysqlが入っていなかったっぽい…
ってことでインストール。

$ brew install mysql

mysqlインストール後にbundle install叩いたら無事解決。

結論

赤字になっていなかったログを見過ごしていた。
ログは最初から読もう。

19
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
10