Posted 3 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)

Copy
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:

Copy
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:

Copy
gem install bundler -v '~>2'

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

Copy
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

Copy
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.

By refactoring problematic code and creating automated tests, makandra can vastly improve the maintainability of your Rails application.

Owner of this card:

Avatar
Thomas Tasler
Last edit:
about 1 month 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