LoginSignup
0
0

More than 5 years have passed since last update.

bundle installのmysql2 のエラー解決方法

Last updated at Posted at 2019-02-28

【環境】
macOS Mojava
バージョン10.14.3

・ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin18]

・rbenv versions
system
2.2.2
2.3.0
2.3.1
* 2.3.3 (set by /Users/ユーザー名/サイト名/.ruby-version)
2.4.1
2.5.3

mysql --version

/usr/local/opt/mysql@5.7/bin/mysql Ver 14.14 Distrib 5.7.25, for osx10.14 (x86_64) using EditLine wrapper

vi ~/.bash_profile

PATH=/usr/local/mysql/bin:$PATH
export PATH
export PATH="~/.rbenv/shims:/usr/local/bin:$PATH"

eval "$(rbenv init -)"

vi ~/.bashrc

alias mysql=/usr/local/opt/mysql@5.7/bin/mysql

alias mysqladmin=/usr/local/opt/mysql@5.7/bin/mysqladmin

【エラー内容】

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

Gem files will remain installed in
/Users/ユーザー名/サイト名/vendor/bundle/ruby/2.3.0/gems/mysql2-0.4.5 for
inspection.
Results logged to
/Users/ユーザー名/サイト名/vendor/bundle/ruby/2.3.0/extensions/x86_64-darwin-18/2.3.0-static/mysql2-0.4.5/gem_make.out

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

In Gemfile:
mysql2



【試した事】

・パスを通す
https://nekonenene.hatenablog.com/entry/2016/10/31/061350
の解決方法①

bundle config build.mysql2 --with-opt-lib=/usr/local/opt/openssl/lib --with-opt-include=-I/usr/local/opt/openssl/include

・インストール実行
gem install mysql2 -v '0.4.5' --source 'https://rubygems.org/'

▼エラー内容
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.


・gemfileのtherubyracerをコメントアウト

gem 'therubyracer'


・Xcodeの再インストール
xcode-select --install

▼エラー内容(インストール済)

xcode-select: error: command line tools are already installed, use "Software Update" to install updates

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