DEV Community

tanakaworld
tanakaworld

Posted on

You Must Use Bundler 2 or Greater With This Lockfile. How to resolve "You must use Bundler 2 or greater with this lockfile"

I've written the same article in Japanese.

bundler 2.x has been released on Jan 4th 2019.

BUNDLED WITH in Gemfile.lock is rewritten when you run bundle update with bundler 2.x in your machine.



$ bundle update
•••

$ git diff
•••
 BUNDLED WITH
-   1.17.3
+   2.0.1


Enter fullscreen mode Exit fullscreen mode

This change would make some problems on CircleCI and production environment etc.

You must use Bundler 2 or greater with this lockfile.
image.png

Solution A: Downgrade the bundler

Check the current version



$ cat Gemfile.lock | grep "BUNDLED WITH" -A 1
BUNDLED WITH
2.0.1

Enter fullscreen mode Exit fullscreen mode




Recreate Gemfile.lock with the older version




$ gem install bundler -v 1.17.3
$ rm Gemfile.lock
$ bundle 1.17.3 install

Enter fullscreen mode Exit fullscreen mode




Confirm




$ cat Gemfile.lock | grep "BUNDLED WITH" -A 1
BUNDLED WITH
1.17.3

Enter fullscreen mode Exit fullscreen mode




Solution B: Change the bundler version in the environment.

  1. Set any version as BUNDLER_VERSION
  2. Reinstall the bundler


version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/ruby:2.6.0-node-browsers
environment:
# 1
BUNDLER_VERSION: 2.0.1

  # Specify service dependencies here if necessary
  # CircleCI maintains a library of pre-built images
  # documented at https://circleci.com/docs/2.0/circleci-images/
  # - image: circleci/postgres:9.4

working_directory: ~/repo

steps:
  - checkout

  # 2
  - run:
      name: setup bundler
      command: |
        sudo gem update --system
        sudo gem uninstall bundler
        sudo rm /usr/local/bin/bundle
        sudo rm /usr/local/bin/bundler
        sudo gem install bundler

  # •••

  - run:
      name: install dependencies
      command: |
        bundle install --jobs=4 --retry=3 --path vendor/bundle
Enter fullscreen mode Exit fullscreen mode
Enter fullscreen mode Exit fullscreen mode




References

Top comments (0)