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

bundler
known-issue
circle.yml

#1

We set bundler to a fixed version (1.10.6) on CircleCI. We have a block in circle.yml as follows to set up that dependency:

dependencies:
  pre:
    - gem install bundler -v 1.10.6

Despite this step explicitly succeeding without errors here:

gem install bundler -v 1.10.6Fetching: bundler-1.10.6.gem (100%)
Successfully installed bundler-1.10.6
1 gem installed

The inferred step later marked “bundle install” sometimes fails (on 1-2 of our 3 containers) as follows:

bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 Resolving dependencies...
Bundler can't satisfy your Gemfile's dependencies.
Install missing gems with `bundle install`.
Fetching gem metadata from https://rails-assets.org/...
Fetching version metadata from https://rails-assets.org/..
Fetching gem metadata from https://rails-assets.org/...
Fetching gem metadata from https://rubygems.org/........
Fetching version metadata from https://rails-assets.org/..
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rails-assets.org/..
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Bundler could not find compatible versions for gem "bundler":
  In Gemfile:
    bundler (>= 1.10.6) ruby

  Current Bundler version:
    bundler (1.9.5)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?

bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3  returned exit code 6

Could not find gem 'bundler (>= 1.10.6) ruby in any of the sources
Action failed: bundle install

The failure started today (March 18, 2016) and has affected many branches, effectively making CircleCI unusable for us. No bundler/Gemfile related changes have occurred in the week prior to the problem appearing.


#2

I am getting the exact same issue.

I tried updating to bundler 1.11.2 (both in gemfile and in circle.yml) and I get the same problem.


#3

As a work around, I removed bundler entirely from my Gemfile (and gemfile.lock), since my project is in a private repo. Not sure why it was there, unless it was to insure that devs aren’t using an old bundler.

That works for now, and allows me to keep deploying and testing.


#4

In our case, we are intentionally using it to ensure a sufficiently high version of bundler by developers and ensure compatibility with our production environment. Developers have a little more leeway (hence the >=).

I’ve applied your workaround temporarily (appears to work), but I would still like feedback from Circle team about how to fix this properly. We’ve been solid red for a couple days now, making Circle basically unusable with no relevant changes on our side.


#5

Thanks for the workaround. It fixed my build as well but just like CJBridges, we needed a specific version to make sure our dev environment and production environment are as close as possible. This was working 3 days ago but somehow started acting up today. Any comments or feedback from the CircleCI team would be really appreciated.


#6

Same issue here. Something changed on their end making this piece of documentation wrong: https://circleci.com/docs/bundler-latest


#7

I’m also having bundler issues as of Friday (with different symptoms)

If I cd into my project and run

bundle exec bundle list

I get:

/home/ubuntu/.rvm/gems/ruby-2.1.5@global/bin/bundle:22:in `load': cannot load such file -- /home/ubuntu/.rvm/gems/ruby-2.1.5@global/gems/bundler-1.9.5/lib/gems/bundler-1.9.5/bin/bundle (LoadError)

#8

I am also getting the same loading error with ruby 2.0.0-p481 , bundler-1.9.5


#9

We are investigating this issue on our end but it looks like this may be tangentially related to a couple of updates that we performed on the images for security reasons. For now we recommend using the workaround tomfbiz posted. Once we have a more permanent solution in place we will provide an update.


#10

That LoadError now hits us as well. We don’t have any explicit version constraint in circle.yml or Gemfile. bundle install says “Using bundler 1.9.5” and then our CI task fails:

bundle exec rake test
Running RuboCop...
Inspecting 139 files
...........................................................................................................................................

139 files inspected, no offenses detected
bundle exec rails_best_practices /home/ubuntu/PROJECT
/home/ubuntu/.rvm/gems/ruby-2.2.3@global/bin/bundle:22:in `load': cannot load such file -- /home/ubuntu/.rvm/gems/ruby-2.2.3@global/gems/bundler-1.9.5/lib/gems/bundler-1.9.5/bin/bundle (LoadError)
	from /home/ubuntu/.rvm/gems/ruby-2.2.3@global/bin/bundle:22:in `<main>'

#11

That workaround is not an option for anyone using the “rails” gem


#12

One of our support engineers was just able to find a solution to this issue by switching to the rvm global gemset.

ubuntu@box1115:~$ rvm @global
Warning! PATH is not properly set up, '/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/bin' is not at first place,
         usually this is caused by shell initialization files - check them for 'PATH=...' entries,
         it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
         to fix temporarily in this shell session run: 'rvm use ruby-1.9.3-p448'.
ubuntu@box1115:~$ gem list

*** LOCAL GEMS ***

bundler (1.9.5)
diff-lcs (1.2.5)
rspec (3.4.0)
rspec-core (3.4.3)
rspec-expectations (3.4.0)
rspec-mocks (3.4.1)
rspec-support (3.4.1)

ubuntu@box1115:~$ gem update bundler
Updating installed gems
Updating bundler
Fetching: bundler-1.11.2.gem (100%)
Successfully installed bundler-1.11.2
Gems updated: bundler

ubuntu@box1115:~$ rvm @default
ubuntu@box1115:~$ gem list

*** LOCAL GEMS ***

gem-wrappers (1.2.7)

Does that work for you?


#13

Workaround for us at the moment is to detect whether the CIRCLECI variable is set and if it is then use the explicit path to the bundler that we installed earlier in the build, since it is there (for example, in $GEM_HOME/gems/bundler-1.10.4/bin/bundle), it’s just not on the path. It seems that it is not the version in $GEM_HOME/bin.


#14

@sean Can we get a status update on when this bug will be fixed?


#15

I have removed bundler from my Gemfile and gemfile.lock and my build still says Using bundler 1.9.5. The suggested solution above is not a solution for all.


#16

We are actively investigating this problem right now but don’t have an ETA on a solution. Once we have a permanent solution in place I’ll update this topic.


#17

I’ve taken look at the issue. It seems the issue is gem install bundler updates globally installed bundler, not rvm-installed bundler for some reasons.

The workaround is uninstalling globally installed bundler first.

dependencies:
  pre:
    - echo Y | rvm @global do gem uninstall bundler
    - gem install bundler -v '1.10.6'

Working demo: https://circleci.com/gh/kimh/circleci-playground/62#config

Another indirect solution is using Ruby 2.3.0 which comes with bundler 1.11.0 and bundle install doesn’t complain Bundler could not find compatible versions for gem "bundler": anymore.

However, I wonder if gem install bundler installing globally installed bundler is a correct behavior. I can see the same issue in the past in SO.


#18

I’ve added in the dependencies step but I’m still getting the LoadError issue. I’ve tried using different versions of bundler and still get the same result.

/home/ubuntu/.rvm/gems/ruby-2.0.0-p481/bin/bundle:22:in load': cannot load such file -- /home/ubuntu/.rvm/gems/ruby-2.0.0-p481/gems/bundler-1.10.6/lib/gems/bundler-1.10.6/bin/bundle (LoadError) from /home/ubuntu/.rvm/gems/ruby-2.0.0-p481/bin/bundle:22:in


#19

After gem install bundler, can you see if gem regenerate_binstubs fixes your issue?


#20

build fails with that. so far, none of these solutions have worked for me