14
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

#Rails の bundle install と bundle update の違いを結論から書く

Last updated at Posted at 2019-09-28

bundle install

  • 初回は Gemfile を元に gem をインストールする。 Gemfile.lock が生成され、 gem のバージョンを固定する。
  • 二回目以降は、Gemfile.lock で固定されたバージョンの通りに gem をインストールする。
  • Gemfile.lock が存在する場合は、誰が bundle install しても同じバージョンの gem がインストールされる。同じ Gemfile.lock がある限り、同じバージョンのgem群を再現できる。(それが ロック だ!)

bundle update

  • Gemfile を元に gem のバージョンをアップデートして、Gemfile.lock を更新する。
  • それぞれのgemのバージョンがどのバージョンアップデートされるかは、Gemfileでのgemのバージョン指定や、gem同士の依存関係による。

つまり

  • Gemfile.lock がある限り、 bundle install した時の gem のバージョンは変わらない。
  • bundle update した後に Gemfile.lock を元に戻してから bundle install すると、gem のバージョンは元に戻る。つまり gem をダウンデートできる。
  • Gemfile.lock がなかったり、削除した場合に bundle install を実行すると、gem のバージョンが固定されていないため、バージョンが変わる可能性がある。
  • Gemfile.lock を削除してから bundle install するのと、 Gemfile.lock がある状態で bundle update する場合では、どちらも可能な限り最新バージョンのgemをインストールしようとするため、同じ結果になる。
  • 初回に bundle install した後に、すぐ bundle update を実行すると、すでに可能な限り 最新バージョンの gem をインストールしているはずなので、何も変わらない。

ツッコミ歓迎

嘘があったら俺を食え。

image

参考

bundle install と bundle updateの違いについて - Qiita

Original by Github issue

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

14
5
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
14
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?