4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Could not find ... in locally installed gems Run bundle install ... to install missing gems. エラー

4
Posted at

はじめに

Could not find ... in locally installed gems Run bundle install ... to install missing gems. エラーについて、毎回何のコマンド実行すればいいんだっけとなり、思考停止でAIに任せていたので、まとめました。

問題

RailsをDockerで動かしています。

下記の流れで作業をしていました。

  1. Gemを更新するタスク
  2. モデルにフィールドを追加する機能改修のタスク
  3. 別の機能改修のタスク

3番目のタスクに移った時、
ActiveRecord::PendingMigrationError になったので、docker compose exec app rails db:migrateを実行したら下記のエラーが出ました。

Could not find ... in locally installed gems Run bundle install ... to install missing gems.

Gemfile.lock に更新された Gem が記載されているのに、コンテナ内の Gem が古いままになっており、ローカルのブランチ切り替えだけで満足して、bundle install をすっぽかしたことが原因でした。

解決方法

下記の順でコマンドを実行します。
イメージを作り直して、そのイメージで新しいコンテナを立ち上げて、migrateすれば解決しました。

  1. docker compose build app sidekiq
  2. docker compose up -d
  3. docker compose exec app rails db:migrate

おわりに

急がず、手順通りに作業をらせてから、作業を切り替えるように気をつけようと反省しました。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?