Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What is going on with this article?
@dichikawa

あともう少し。MySQLサービス起動後、Railsサーバが起動しない3

発生した背景

MySQLサービスが復旧したところで、Railsを起動すると以下のエラーが発生した。

/Users/ichikawadaisuke/projects/krown/vendor/ruby/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': dlopen(/Users/ichikawadaisuke/projects/krown/vendor/ruby/2.5.0/gems/mysql2-0.5.2/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/opt/mysql/lib/libmysqlclient.21.dylib (LoadError)
  Referenced from: /Users/ichikawadaisuke/projects/krown/vendor/ruby/2.5.0/gems/mysql2-0.5.2/lib/mysql2/mysql2.bundle
  Reason: image not found - /Users/ichikawadaisuke/projects/krown/vendor/ruby/2.5.0/gems/mysql2-0.5.2/lib/mysql2/mysql2.bundle

対応手順

MySQLサービスを再インストールしたため、既存のGemが動作しなくなったと判断。
Gemの再セッティングを実施する。
①以下コマンドにて原因を多角的に調査する

$ bundle update
$ rails s
(これで復旧するかを試してみるも、Railsサーバは起動しなかった)
$ bundle doctor
(MySQLに紐つくような目立ったエラーは発生していない)

②以下のコマンドでGemを入れ替える

$ bundle exec gem uninstall mysql2
Successfully uninstalled mysql2-0.5.2
$ bundle install --path vendor
(同コマンドで改めてGemを入れなおす)

③やっと…Railsが起動した…

Use Ctrl-C to stop
Started GET "/" for ::1 at 2020-06-02 18:46:42 +0900
ActiveRecord::NoDatabaseError (Unknown database 'krown_development'):

④あとはお決まりのコマンドを実行して、無事終了しました😆

$ bundle exec rake db:create
$ bundle exec rake db:migrate
0
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
0
Help us understand the problem. What is going on with this article?