LoginSignup
20
18

More than 5 years have passed since last update.

gem mysql2がインストールできなかった時の対処

Posted at

railsをインストールしてプロジェクトを作成し、サーバーを起動して
とりあえずHello worldしようと思った。 が、こけた

$ rails new [project_name] -d mysql -B

mysql2のgemがないと言われている

$ rails server
Could not find gem 'mysql2 (< 0.6.0, >= 0.4.4)' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.

検索して
https://qiita.com/nakki/items/e15c6b024d27edb2b96b
この辺りの記事を見つけたのでxcodeをアップデートとか必要なのかな・・・・?

と思っていたが、単にこの環境にmysqlが入っていなかっただけだった・・・

$ brew install mysql
$ brew upgrade mysql

このあとpumaとかsassとか古いgemがいくつかあったのだが、

$ bundle install
$ gem update

などしてrailsに必要なgemを揃えた。

$ rails server
=> Booting Puma
=> Rails 5.2.1 application starting in development 
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.0 (ruby 2.5.1-p57), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
Started GET "/" for 127.0.0.1 at 2018-10-23 22:14:02 +0900

localhostに3000番ポートでアクセスしていけました。

参考

20
18
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
20
18