LoginSignup
37
42

More than 5 years have passed since last update.

bundle install と updateの違い

Last updated at Posted at 2015-03-08

まずは改めて各ファイルの役割から。

Gemfile:必要となるgemを記述します。
Gemfile.lock:現在使用しているgemのバージョンおよび特定のgemを使うためにインストールする必要のあるgemの一覧が管理されます。

んで、bundle installbundle updateですが、

bundle installGemfileに更新があれば、未インストールのgemがインストールされ、Gemfile.lockが更新される。更新がなければGemfile.lockに従ってgemの更新を行う。Gemfile.lockが存在しない場合はGemfileに従ってgemの更新を行い、Gemfile.lockを作成する。
bundle updateGemfileに従ってgemの更新を行い、Gemfile.lockを上書きする。

ということでした。PHPでcomposerはバンドルをcomposer.jsonに追加した際に、composer updateをするので、gem追加時にbundle installをすることに慣れず、ちょっと戸惑いました。インストールしたgemは私の環境ではrbenvというRubyのバージョンを簡単に変更できるサービスを利用しているので、/home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/に保存されていました。

ユースケースとしては

  • 新環境で開発スタート:bundle install
  • 開発中に新しいgemを追加:bundle updateで常にバンドルを最新版に保つ
  • デプロイ:bundle install

って感じがいいのかな、と思いました。開発環境だとできるだけbundle updateして、バンドルを最新版に保っておいてあげると仲間から喜ばれそうですね。くれぐれも本番環境でbundle updateだけはアウトです。これはcomposerも一緒。

37
42
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
37
42