Using Bundler 2.0 during CI fails

Hi, I’m having trouble with using Bundler 2.0 on Circle CI 2.0.

I’ve checked a 2 years old issue that’s been resolved, tried several configuration but none worked.

When upgrading bundler to 2.0 it works :

        gem update bundler

Or if we uninstall and reinstall

        gem uninstall bundler
        gem install bundler

Same result :

Fetching bundler-2.0.0.gem
Successfully installed bundler-2.0.0
1 gem installed

But when we run :

        bundle install --deployment --path vendor/bundle

We get this error :

You must use Bundler 2 or greater with this lockfile.
Exited with code 20

We running a debug session via SSH, bundler version stays at 1.x

We have deployed apps with Bundler 2.0 with any problem today.

3 Likes

It works for me using this workaround:

  1. Set the version of bundler as an environment variable:
docker:
    - image: circleci/ruby:2.6.0-node
      environment:
        BUNDLER_VERSION: 2.0.1

2 - Running these steps before bundle install

sudo gem update --system
sudo gem uninstall bundler
sudo rm /usr/local/bin/bundle
sudo rm /usr/local/bin/bundler
sudo gem install bundler

I guess the solution here is that circleci/ruby:2.6.0-node image comes with Bundler 2 by default.

2 Likes

I made it work adding a new step that makes sure the right bundler version is used before building. The bundler version is obtained from the last line of the Gemfile.lock.

  - run:
      name: Configure Bundler
      command: |
        echo 'export BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")' >> $BASH_ENV
        source $BASH_ENV
        gem install bundler
8 Likes

Great answers, thanks a lot ! Ruby 2.6 or using Bundler 2.0.1 (which came out after this post being created) helped !

@bustikiller It worked for me. Thank man!
Bundler 2.0.1 && ruby 2.6.1

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.