Bundler fails to find appropriate version, despite installing appropriate version earlier in the build

Okay, that’s interesting. gem regenerate_binstubs is provided by the executable-hooks gem via rubygems-bundler, which RVM installs by default. That extension should be available to the gem command if it’s the version installed by RVM…

In any case, while we work on a better solution, gem install bundler -v 1.10.6 && gem install rubygems-bundler && gem regenerate_binstubs should make the version of bundler available that you want (it might need to be combined Kim’s suggested echo Y | rvm @global do gem uninstall bundler )

1 Like

This still isn’t working for me. Any ETA on when this is going to be fixed? It is completely breaking our builds.

None of the above solutions work for me either using ruby 2.3.0, and we likewise can’t complete any builds without a resolution. I have attempted these steps in the override and post dependencies steps with no luck:

- echo Y | rvm @global do gem uninstall bundler
- gem install bundler -v 1.11.2 && gem install rubygems-bundler && gem regenerate_binstubs

I’ve also tried pointing Circle directly to the binary, which it finds, but then fails. Oddly, this exact command works properly when I SSH into the build and run it.

[pollinate] Running RACK_ENV=development BUNDLE_GEMFILE=./Gemfile /home/ubuntu/.rvm/gems/ruby-2.3.0/bin/bundle exec rails db:create db:schema:load in /home/ubuntu/pollinate-v4/api
/home/ubuntu/.rvm/gems/ruby-2.3.0/bin/bundle:22:in `load': cannot load such file -- /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/bundler-1.11.2/lib/gems/bundler-1.11.2/bin/bundle (LoadError)
	from /home/ubuntu/.rvm/gems/ruby-2.3.0/bin/bundle:22:in `<main>'
	from /home/ubuntu/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
	from /home/ubuntu/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'

It’s correct – /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/bundler-1.11.2/lib/gems/bundler-1.11.2/bin/bundle does not exist. I just don’t know why it’s looking for it. (It doesn’t look for it when the command is run via SSH.)

I was running into the same with v1.11.2. If you use 1.10.6 explictly, it should work.

This is what I am doing in my circle.yml (dependencies:pre):

rvm @global do gem uninstall bundler -a -x
gem install bundler -v 1.10.6
gem install rubygems-bundler
gem regenerate_binstubs

FWIW, not sure if this is compounding the situation, but it appears >=1.11.x also has some similiarly weird issues being investigated by the bundler team, related to binstubs and nested bundle exec calls.

Thanks for the input @brentlintner. Sadly this does not work for me for the same reason as before (except now with the new bundler version :stuck_out_tongue:) .

circle.yml

dependencies:
  pre:
    # https://discuss.circleci.com/t/bundler-fails-to-find-appropriate-version-despite-installing-appropriate-version-earlier-in-the-build/2815/23
    - rvm @global do gem uninstall bundler -ax
    - gem install bundler -v 1.10.6
    - gem install rubygems-bundler
    - gem regenerate_binstubs

  override:
    - cd cli; ./install
    - cd cli; ./pollinate setup

Output:

[pollinate] Running RACK_ENV=development BUNDLE_GEMFILE=./Gemfile bundle exec rails db:create db:schema:load in /home/ubuntu/pollinate-v4/api
/home/ubuntu/.rvm/gems/ruby-2.3.0/bin/bundle:22:in `load': cannot load such file -- /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/bundler-1.10.6/lib/gems/bundler-1.10.6/bin/bundle (LoadError)
	from /home/ubuntu/.rvm/gems/ruby-2.3.0/bin/bundle:22:in `<main>'
	from /home/ubuntu/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
	from /home/ubuntu/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'

cd cli; ./pollinate setup returned exit code 1

The path it’s looking for bundle in looks weird: /home/ubuntu/.rvm/gems/ruby-2.3.0/gems/bundler-1.10.6/lib/gems/bundler-1.10.6/bin/bundle. Is that really where it’s supposed to live, or is that command getting generated incorrectly somehow?

The line that’s complaining in the bundler executable is simply:

gem ‘bundler’, version

Can any CircleCI staff inform us on what the problem is? I have tried explicitly setting bundler versions and ruby versions through rvm’s global gemset but still get the LoadError issue when I try to run my builds.

Same issue here; brentlintner’s fix didn’t help. :frowning:

This issue is currently disrupting our entire CI flow, we would appreciate some indication of a timeline / root-cause / work-around that we could use effectively to get around this issue!

3 Likes

Any updates on this issue?

Update:

The issue is that in our recent container image update, we upgraded Rubygems from 2.6.0 to 2.6.2. This is a bug in Rubygems 2.6.2, which is fixed by this Rubygems commit. There isn’t a new version of Rubygems available yet, but you can install the head version with:

dependencies:
  pre:
    - rvm install rubygems head
    - gem install bundler -v '1.10.6'

Edit: Rubygems 2.5.2 works as well. I’d advise against the 2.6.x series as I’ve seen install problems on each version for our customers.

Unfortunately, it doesn’t work for my build…
Following dirty workaround works:

dependencies:
  pre:
    - gem install bundler -v '1.11.2'
    - sed -i -e "s/Gem.activate_bin_path('bundler', 'bundle', version)/'\/home\/ubuntu\/.rvm\/gems\/ruby-2.3.0\/gems\/bundler-1.11.2\/exe\/bundle'/g" /home/ubuntu/.rvm/gems/ruby-2.3.0/bin/bundle

So the planets have aligned to give us a bug in bundler at the same time as a bug in Rubygems. Maybe now is a good time to buy a lottery ticket :slight_smile:

The bundler bug seems specific to Rubygems 2.6.2, though it’s present in Rubygems-head as well. I’ve tried this against Bundler 1.12.0.rc and it appears that the issue is still around. I’ve reproduced the load error and made it go away with an older version of Rubygems. Here’s the circle.yml file:

dependencies:
  pre:
    - gem -v
    - rvm @global do gem uninstall bundler -ax
    - rvm install rubygems 2.4.8 --force
    - gem install bundler --pre
    - bundle -v

test:
  override:
    - bundle -v
    - bundle exec bundle -v

Without the rvm install rubygems 2.4.8 --force line, you’ll see the load error.

1 Like

It works! Many thanks @Eric. These were the only lines I needed:

dependencies:
  pre:                                                                                                                                                                       
    - rvm install rubygems 2.4.8 --force                                                                                                                                     
    - gem install bundler -v 1.11.2

We were able to work around our problem by not 'double bundle exec’ing … basically we had a rake task that also ran a system() call to bundle exec … which is directly related to the bug opened on the bundler project

Rubygems 2.6.3 is released now by the way. Any plans on upgrading soon?

Thanks for bringing that to our attention, we tested out Rubygems 2.6.3 and got the following:

ubuntu@box999:~$ bundler -v && gem install bundler -v 1.11.2 && bundler -v
Bundler version 1.9.5
Fetching: bundler-1.11.2.gem (100%)
Successfully installed bundler-1.11.2
1 gem installed
Bundler version 1.11.2
ubuntu@box999:~$ bundler --version
Bundler version 1.11.2

So it looks like it will solve the rvm @global gem uninstall bundler workaround earlier in this thread. We’re rolling it into our next image update, which will be out soon. The issue with a double-wrapped bundle exec is not yet fixed in bundler. It’s latest stable version is still 1.11.2.

1 Like

You can ignore global gemsets with rvm_ignore_gemsets_flag option. See https://rvm.io/gemsets/ignoring

dependencies:
  pre:
    - echo "export rvm_ignore_gemsets_flag=1" >> ~/.rvmrc
    - gem install bundler

works in my project. Just for your information.

2 Likes

If you have problem with random failing bundler on CI then you may want to switch to Ubuntu 14.04 (Trusty) image in Project Settings -> Build Environment.

Example error I had on Ubuntu 12.04 image:

/home/ubuntu/.rvm/gems/ruby-2.3.0@global/bin/bundle:22:in `load': cannot load such file -- /home/ubuntu/.rvm/gems/ruby-2.3.0@global/gems/bundler-1.9.5/lib/gems/bundler-1.9.5/bin/bundle (LoadError)
from /home/ubuntu/.rvm/gems/ruby-2.3.0@global/bin/bundle:22:in `<main>'
1 Like

Nice to see you here @ArturT - can confirm that using Ubuntu 14.04 fixes the bundler version issue.

Worth noting that Circle’s Ubuntu 14.04 has different package versions pre-installed. Verify that they align with your project’s dependencies, otherwise your build may break or slow down by having to install a specific package version every time. Details at https://circleci.com/docs/build-image-trusty

1 Like

Modifying both gemfiles from rake 10.0 to rake 11.2.2 did the trick (in my case). Running *buntu 16.04.