LoginSignup
2
0

More than 3 years have passed since last update.

RubyでMySQL2をインストールする必要があったときの対処方法(Mac)

Last updated at Posted at 2019-06-25

Rubyで新しくプロジェクトを作成するときに下記を実行したところ、MySQL2がないと怒られました。

$ rails new scaffold_app -d mysql

(中略)
An error occurred while installing mysql2 (0.5.2), and Bundler cannot
continue.
Make sure that `gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'`
succeeds before bundling.

(略)

これに対しての対処を以下にまとめます。

環境

  • Mac OS Mojave 10.14.5
  • Ruby 2.6.3

Mojave用macOS SDK header追加してみる

Mojave用のmacOS SDK headerの追加を実行しました。

$ sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

参考:[MacOS Mojave]mysql2のbundle installに失敗してハマった件 - Qiita

エラーログのコマンドを実行してみる

$ gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'

Building native extensions. This could take a while...
Successfully installed mysql2-0.5.2
Parsing documentation for mysql2-0.5.2
Installing ri documentation for mysql2-0.5.2
Done installing documentation for mysql2 after 0 seconds
1 gem installed

すると、無事にMySQL2はインストールできたみたいです。

2
0
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
2
0