エラー内容
$ bundle install
Errno::EACCES: Permission denied @ rb_sysopen -
/Users/username/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/mysql2-0.5.2/gem_make.out
An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.5.2'` succeeds before bundling.
$ gem install mysql2 -v '0.5.2'
Building native extensions. This could take a while...
ERROR: While executing gem ... (Errno::EACCES)
Permission denied @ rb_sysopen - /Users/username/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/mysql2-0.5.2/gem_make.out
やったこと
$ ls -ltr /Users/username/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/doc/
root 権限で install されていたので一旦消す
$ sudo rm -rf /Users/username/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/mysql2-0.5.2/
再インストール
$ gem install mysql2 -v '0.5.2'
参考
https://qiita.com/akito19/items/e1dc54f907987e688cc0
https://qiita.com/mitsuaki1229/items/2b89640ca9fe25555328