bootsnap: Bundler 1.16.0 errors on Circle CI with load_path_cache

We started receiving errors on CirrleCI, I think they might have updated the docker image circleci/ruby:2.4-node-browsers to use newer bundler (1.15 => 1.16) or newer ruby version (2.4.1 => 2.4.2) or both.

This looks like a bug in bootsnap or bundler, because withtout bootsnap everything works ok.

It doesn’t work with bootsnap + bundler 1.16 + load_path_cache: true on CircleCI. It works with bootsnap + bundler 1.16 + load_path_cache: false on CircleCI. It works with bootsnap + bundler 1.15 + load_path_cache: true on CircleCI.

The problem might be bundler 1.16 + bootsnap, but I can’t reproduce this on OSX, only in CircleCI, haven’t tried this on other linux machines.

Any ideas how to fix or debug this?

The error when running rails c:

/usr/local/lib/ruby/site_ruby/2.4.0/bundler/runtime.rb:84:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'dotenv-rails'. (Bundler::GemRequireError)
Gem Load Error is: Trying to register Bundler::GemfileError for status code 4 but Bundler::GemfileError is already registered
Backtrace for gem load error is:
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/errors.rb:9:in `status_code'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/errors.rb:20:in `<class:GemfileError>'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/errors.rb:20:in `<module:Bundler>'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/errors.rb:3:in `<main>'
/home/circleci/app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.1.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'
/home/circleci/app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.1.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'

Full log: https://gist.github.com/ebeigarts/3d4d2c03aec360fecd4132dd062a1589

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 7
  • Comments: 17 (5 by maintainers)

Commits related to this issue

Most upvoted comments

I just worked around this by changing my boot.rb to the following:

ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)

require 'bundler/setup' # Set up gems listed in the Gemfile.
require 'bootsnap'
env = ENV['RAILS_ENV'] || 'development'
circle_off = ENV['CIRCLECI'].nil?
Bootsnap.setup(
  cache_dir: 'tmp/cache',
  development_mode: env == 'development',
  load_path_cache: circle_off,
  autoload_paths_cache: circle_off,
  disable_trace: true,
  compile_cache_iseq: true,
  compile_cache_yaml: true
)

Check checks for the CIRCLECI environment variable and turns off load_path_cache and autoload_paths_cache when using Circle.

Great! I just released 1.2.0 so I’ll close.

Hi, I removed require 'bootsnap/setup' from boot.rb and worked for me.

This occurs for me locally with Rubygems 2.7.5. Downgrading to 2.7.4 fixes it: gem update --system 2.7.4 rvm all do gem update --system 2.7.4

I experienced the same issue in a docker image and with 1.2.0.pre it works fine!! 👍

The above boot.rb did not work for me. I ended up using this and it works.

ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)

require 'bundler/setup' # Set up gems listed in the Gemfile.
require 'bootsnap/setup' unless ENV['CIRCLECI']

Just an FYI @wellington1993 … that removes Bootsnap from your application entirely, which is why you saw this work.

We haven’t been able to replicate this error at all, so it’s been difficult to look into. We just had someone replicate it locally so we should be able to look into what is happening here.

Sorry for the delay.

I was having this issue on CircleCI and 1.2.0.pre seems to have fixed it! 👍