LoginSignup
84
66

More than 3 years have passed since last update.

"You must use Bundler 2 or greater with this lockfile" に対応する

Last updated at Posted at 2019-03-24

2019年1月4日に bundler の 2.X 系がリリースされた.2.X 系の bundler がインストールされている状態で bundle update などすると Gemfile.lock の BUNDLED WITH が書き換わる.

$ bundle update
•••

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

bundler 2.X 系で作成された Gemfile.lock ファイルが CircleCI 上で bundle install できないなどが発生する件に対応する.

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

1. ダウングレードするパターン

現在のバージョンをチェック

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

旧バージョンで Gemfile.lock を生成しなおす

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

更新チェック

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

2. CircleCI 上などで 2.X 系を使えるようにするパターン

  • BUNDLER_VERSION で任意のバージョンを指定
  • ② bundler を入れ直す
.circleci/config.yml
version: 2
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/ruby:2.6.0-node-browsers
        environment:
          # ①
          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

      # ②
      - 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

参考

84
66
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
84
66