bundle installとbundle update、gemfileとgemfile.lockのつながりを解いてみた

自分のあたまを整理するために書きます。

まずgemfileから

必要なgemを自分でgemfileに追記します。
f:id:shounen070505:20171109203505p:plain

bundle installを実行する

bundle install

するとbundlerが各gemの依存関係を調べた上で、 各gemのバージョンを調整してインストールしてくれます。

f:id:shounen070505:20171109203921p:plain

その結果を、gemfile.lockに保存します。
f:id:shounen070505:20171109204845p:plain

gemfile.lock

GEM
  remote: https://rubygems.org/
  specs:
    CFPropertyList (2.3.5)
    actionmailer (4.2.3)
      actionpack (= 4.2.3)
      actionview (= 4.2.3)
      activejob (= 4.2.3)
(省略)
  turbolinks
  twitter-bootstrap-rails
  uglifier (>= 1.3.0)
  unicorn
  web-console (~> 2.0)

BUNDLED WITH
   1.15.3

bundle updateをしてみる

bundle update


これを実行すると、gemfile.lockを完全に無視して、gemfileだけを見て、
各gemを最新のバージョンにしつつ、やはり依存関係の調整をしてくれます。
で、その結果をgemfile.lockに保存します。