Read more

Bundler 2.3 honors the version specified in `BUNDLED_WITH`

Avatar
Klaus Weidinger
January 16, 2023Software engineer at makandra GmbH

Bundler so far ignored the version specified under BUNDLED_WITH in the Gemfile.lock. This had two annoying consequences:

  • If the bundler version on your system was lower than in the Gemfile.lock, you got an error message and had to manually install the correct version.
  • If the bundler version on your system was higher than in the Gemfile.lock, bundler silently updated the version in the Gemfile.lock to your system's bundler version. To avoid this, you had to always specify, which version you want to use for each bundler command, e.g. bundler _2.1.4_ update

New behavior

Bundler now honors the version specified under BUNDLED_WITH in the Gemfile.lock. The necessary version will automatically be installed, if missing.
This requires bundler 2.3 and rubygems 3.3
For more details, see: https://bundler.io/blog/2022/01/23/bundler-v2-3.html Show archive.org snapshot

Updating bundler

Illustration book lover

Growing Rails Applications in Practice

Check out our e-book. Learn to structure large Ruby on Rails codebases with the tools you already know and love.

  • Introduce design conventions for controllers and user-facing models
  • Create a system for growth
  • Build applications to last
Read more

Determine your currently used bundler version:

bundler -v

Caution: this might already be influenced by a Gemfile.lock in your current directory. Run this command in two projects with different bundler versions in their Gemfile.lock and see if your bundler versions changes automatically. Then you probably already have the new versions.

Install a new bundler version:

# specific version
gem install bundler:2.3.11

# newest version
gem install bundler

I recommend to execute the previous command in the parent folder of all your git repos.

Updating rubygems

Determine the installed version:

gem --version

Update your rubygems version

gem update --system

Updating the bundler version for a project

With the new behavior bundler should never update its version in a Gemfile.lock automatically anymore. Therefore, unless there are reasons for using an older version, it is recommended to upgrade the bundler version for each project manually every once in a while. Good occasions would be the start and end of a development block.

Update the bundler version under BUNDLED_WITH in the Gemfile.lock:

bundle update --bundler
Posted by Klaus Weidinger to makandra dev (2023-01-16 18:34)