Bundler の基本的な使い方

Bundler のインストール

% rbenv exec gem install bundler
% rbenv rehash
% bunder -v

rbenv rehash はコマンドプログラムの更新
rbenv のヘルプには次のようにある

Rehash rbenv shims (run this after installing executables)

Bundler で gem をインストールする

Gemfile を作って編集し bundle install

% bundle init
% vi Gemfile
% rbenv exec bundler install

すると Gemfile.lock ファイルが作成される


注意!ここから先は未確認・未検証!

別環境で gem をインストールする

% rbenv exec bundler install

Gemfile.lock が存在し Gemfile が更新されていなければ Gemfile.lock に従う (Gemfile.lock は更新されない)
Gemfile.lock が存在し Gemfile が更新されている場合、更新された gem に対して依存性の再解決を行う

以下、bundler install のヘルプより引用

Install the gems specified in your Gemfile(5). If this is the first time you run bundle install (and a Gemfile.lock does not exist), Bundler will fetch all remote sources, resolve dependencies and install all needed gems.

If a Gemfile.lock does exist, and you have not updated your Gemfile(5), Bundler will fetch all remote sources, but use the dependencies specified in the Gemfile.lock instead of resolving dependencies.

If a Gemfile.lock does exist, and you have updated your Gemfile(5), Bundler will use the dependencies in the Gemfile.lock for all gems that you did not update, but will re-resolve the dependencies of gems that you did update. You can find more information about this update process below under CONSERVATIVE UPDATING.

インストールされている Gem を更新する (version up)

% rbenv exec bundler update

このとき Gem のバージョンが変わると Gemfile.lock が更新される