bundle update 実行時の注意点
アプリケーション開発中に何らかの理由(主に Rails のバージョン更新)で bundle update を実行する際の注意点について。
アプリケーションサーバ(Webrick, Passenger, Unicorn 等)を起動した状態で bundle update を叩くと Gemfile.lock の更新が行われず、再起動時に以下のようなエラーになります。
Bundler could not find compatible versions for gem "activesupport": In snapshot (Gemfile.lock): activesupport (3.2.1) In Gemfile: rails (= 3.2.2) ruby depends on activesupport (= 3.2.2) ruby Running `bundle update` will rebuild your snapshot from scratch, using only the gems in your Gemfile, which may resolve the conflict.
起動中の Rails アプリケーションは Gemfile.lock を参照して利用する gem の判定を行うのですが、どうやらファイル自体もハンドルし続けている様子。素直にサーバを止めてから bundle update を叩き直せば、エラーは解消されます。