Failed to invoke bundler on CircleCI 2.0 with circleci/ruby-2.4.2

docker
circle.yml

#1

Hello. I use CircleCI 2.0 with circleci/ruby-2.4.2 as the executor image, and today I noticed that all my builds fail with the following error (including rebuilding builds that have succeeded yesterday):

/usr/local/bin/bundle:23:in `load': cannot load such file -- /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/exe/bundle (LoadError)
	from /usr/local/bin/bundle:23:in `<main>'
Exited with code 1

I didn’t make any change to my code or CircleCI build configuration (I just changed one commit message to fix a typo then force-pushed).

I connected via SSH and found out that there’s no bundler-1.16.0 subdirectory inside /usr/local/lib/ruby/gems/2.4.0/gems (but there is bundler-1.15.4).

The only reason I can come up with is that it has something to do with CircleCI’s ruby docker images which were updated 7 hours ago.

CircleCI config:

version: 2
jobs:
  build:
    working_directory: ~/my-app

    docker:
      - image: circleci/ruby:2.4.2
        environment:
          HANAMI_ENV: test
          RACK_ENV: test

      - image: redis:4.0.2-alpine

      - image: circleci/postgres:9.6.3-alpine
        environment:
          - POSTGRES_DB: postgres
          - POSTGRES_USER: postgres

    steps:
      - checkout

      - restore_cache:
          key: bundler-{{ checksum "Gemfile.lock" }}

      - run:
          name: Install dependencies
          command: |
            bundle config --local frozen true
            bundle config --local without production:development:staging
            bundle config --local path vendor/bundle
            bundle check || bundle install --jobs=4 --retry=3

      - save_cache:
          key: bundler-{{ checksum "Gemfile.lock" }}
          paths:
            - vendor/bundle

      - run:
          name: Copy configuration files
          command: |
            cp .circleci/config/circle.env .env.test

      - run:
          name: Wait for Postgres
          command: |
            dockerize -wait tcp://localhost:5432 -timeout 1m

      - run:
          name: Setup database
          command: |
            bundle exec rake ci:db:create
            bundle exec hanami db migrate

      - run:
          name: Run Rubocop
          command: bundle exec rubocop

      - run:
          name: Run Rspec
          command: |
            bundle exec rspec

      - store_test_results:
          path: /tmp/test-results

Workarounds:

  • invoke bundler as bundle _1.15.4_;
  • run sudo gem install bundler:1.16.0 before invoking bundler.

#2

Same for image: circleci/ruby:2.3
This was working fine at least on Nov.30, 9pm CET.

The ruby images have been rebuild and tagged within this timeframe:
https://hub.docker.com/r/circleci/ruby/tags/


#3

I can confirm that bundler is broken on 2.3 latest


#4

As a workaround, you can pin the image id using @DIGEST format. Just use the one from your latest successful build. You can find the digest in the “Spin up Environment” section.

e.g. for ruby:2.3

-    - image: circleci/ruby:2.3
+    - image: circleci/ruby:2.3@sha256:b7c0bf563de65c69c5e8fcc7495d2ac24c08b3e94e9ed3228a4a89883f57f7d7

#5

Also having this issue. Could it be related to the new version of rubygems released the other day? http://blog.rubygems.org/2017/11/28/2.7.3-released.html


#6

Confirming that it has been broken since the new images have been released.

A workaround is to use the bundler command instead of bundle, which still works.
So instead of bundle install and bundle exec you would run bundler install and bundler exec.


#7

I ran into this problem today, and submitted a support request. Circle has since pushed a new image, which fixed the problem. I’m using the ruby 2.3.5 image, but I’d assume they updated the other ruby version images as well.

Note that I needed to push a new commit, not just click the “Rebuild” button.


#8

Thanks for the info! Can confirm, it’s working now for the circleci/ruby:2.4.2 image.


#9

I guess I spoke too soon.

My builds have started failing again with the same error.


#10

Still fails for me.

Builds are picking up this tag on 2.4.2:

circleci/ruby@sha256:54aee5ea149b725dffa076a279efe5abb02068a1d9acde471187742dc28d0b6b


#11

I can confirm this is also broken for ruby:2.3.5-node-browsers


#12

Has anyone heard an update from Circle about this? Curious what their support policy is for the docker images they maintain.


#13

I just submitted a support request. I suggest everyone else do the same. You can check image build times here https://hub.docker.com/r/circleci/ruby/tags/


#14

According to support, I got subsequent failures because I was referencing the image by a docker tag name (circleci/ruby:2.3.5-node-browsers), and was getting a cached copy of the image.

Now that more time has passed for all the caches to expire, my builds are passing again.


#15

This is useful.
I’d argue that locking image versions used is not a workaround, but a basic requirement to avoid intermittent build fails.


#16

With the new build it works for me using image: circleci/ruby:2.3


#17

Any node-browsers image working? I just tried switching to - image: circleci/ruby:2.3.5-node-browsers but no luck. I’ve also re-ran the build without cache.


#18

This is an issue with Bundler 1.16.0 that’s packaged with Ruby. On Friday we reverted a prior patch that uninstalled this version and installed 1.15.4. That patch didn’t fully uninstall 1.16.0.

Initial investigations show that it might require rebuilding the image without installing bundler 1.16.0, instead of relying on docker-library/ruby. We’re discussing working with the upstream maintainers to resolve this.

In the mean time, can you try this workaround in your build before using bundler and let us know if it works for you?

    - run: |
        sudo mv /usr/local/lib/ruby/gems/2.4.0/specifications/{default/,}bundler-1.16.0.gemspec
        sudo gem uninstall bundler -a -x
        sudo gem install bundler --version 1.15.4

Note that you’ll have to substitute 2.4.0 for your ruby major version. Do not change the minor version from 0, so you should use 2.3.0, 2.2.0, etc.


Ruby 2.4.2 - failing after latest update
#19

That worked for me! Thanks Eric!


#20

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