Posted 5 months ago. Visible to the public.

Update a projects bundler version

We use bundler to maintain a projects gems. Unfortunately bundler v1 itself is incompatible with bundler v2.
You have two ways to update bundler on the server.

If you use our gem capistrano-opscomplete in your project, you can tell opscomplete to install the required bundler version:

Add the following line to deploy.rb. If you use different deployment targets, add the follwoing line to the specific target configuration file. (e.g production.rb)

set :bundler_version, '<VERSION>' #e.g '~>2'

Bundler v2 needs rubygems 3.0+! You are not sure, weather rubygems 3.0 is already installed on the server or not? Tell opscomplete to install a specific rubygems version as well:

set :rubygems_version, '<VERSION>' #e.g. '3.0.6'

Now update the projects bundler version, push the changes and deploy to the server.

without capistrano-opscomplete

If you need to upgrade bundler to the latest version on a server with opscomplete, you have to do it by yourself:

gem install bundler -v '~>2'

After you installed bundler v2, tell bundler to update your Gemfile.lock and bundler binary

bundle update --bundler bundle install

Common issues / mistakes:
- Be careful! bundler update --bundler produces nearly the same output, but does not update your Gemfile.lock
Even if some people on the web say the bundle and bundler binaries can be used interchangeably.
- Rubygems can't find bundle executable
- Do not change the bundler version in your Gemfile.lock manually, it may work on your local machine, but not on the server.

If you do not need bundler v1 anymore, uninstall the old version with

gem uninstall bundler

Rubygems asks you which version of bundler you want to uninstall.

Now update the project on your local machine the same way, and deploy it to the server.

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

Thomas Tasler
Last edit:
3 months ago
by Thomas Tasler
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Thomas Tasler to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more