18

When I type bundle install I got this error. I tried to find solution but nothing solve my case. Please help me.

 Bundler could not find compatible versions for gem "bundler":
      In Gemfile:
        rails (= 4.1.8) was resolved to 4.1.8, which depends on
          bundler (< 2.0, >= 1.3.0)

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

    Could not find gem 'bundler (< 2.0, >= 1.3.0)', which is required by gem 'rails
    (= 4.1.8)', in any of the sources.

    Bundler could not find compatible versions for gem "rails":
      In Gemfile:
        rails (= 4.1.8)

        animate-rails was resolved to 1.0.10, which depends on
          rails
nourza
  • 2,215
  • 2
  • 16
  • 42

3 Answers3

19

Try to use

gem install bundler -v 1.17.3
bundle _1.17.3_ install
Vivekanand Panda
  • 832
  • 12
  • 23
  • 4
    The second of these commands alone, `bundle _1.17.3_ install`, fixed this issue for me – John Skiles Skinner Sep 05 '19 at 19:23
  • 1
    Yes, but _why_?? This shouldn't be necessary... – Volte Jul 05 '22 at 17:08
  • I you look closely the error also prints the instruction on how to fix it, in my case I had to: error: Install the necessary version with `gem install bundler:2.0.0.pre.3` and rerun bundler using `bundle _2.0.0.pre.3_ install` fix: bundle _2.0.0.pre.3_ install And worked as expected – abdimuna Sep 29 '22 at 06:02
18

Your bundler gem is too big. You can downgrade for now by changing your gemfile to specify the lower version, and deleting the lock file again.

gem 'bundler', '1.17.1' 

Then try these commands in the terminal

gem install bundler -v 1.17.1
gem uninstall bundler -v 2.0.1
bundle update --bundler
bundle install

That last install command might be redundant. I'm on my phone so I can't test anything unfortunately.

Best of luck!

EDIT:

This is now a Heroku issue. Got it. Heroku docs regarding Bundler

Libraries The following libraries are used by the platform for managing and running >Ruby applications and cannot be specified. For application dependency resolution and management, bundler is installed based on the contents of your Gemfile.lock. If you have a BUNDLED WITH in your Gemfile.lock then you will receive a different version of Bundler:

Applications specifying Bundler 2.x in their Gemfile.lock will receive bundler: 2.0.1 Applications specifying Bundler 1.x in their Gemfile.lock will receive bundler: 1.15.2 Applications with no BUNDLED WITH in their Gemfile.lock will default to bundler: 1.15.2 For more information on available settings see Bundler configuration. For more information on why we only support a specific set of bundler versions, please see this article about your Bundler version.

So it seems like Heroku only allows certain versions of Bundler to be compatible, relevant doc is linked. Downgrade to 1.15.2 and give it another shot.

Community
  • 1
  • 1
ShatteredDev
  • 491
  • 3
  • 9
  • Thank you. When I tried to push the update to heroku I got this error Bundler Output: Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.17.1). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`. – nourza Feb 27 '19 at 09:12
  • rb-inotify-0.10.0 requires ruby version >= 2.2, which is incompatible with the remote: current version, ruby 2.0.0p648 – nourza Feb 27 '19 at 09:13
  • oh, then try running all the commands again, but replace the bundler version 1.17.1 with 1.15.2. I saw something specific to Heroku for this, i'll see if I can find it – ShatteredDev Feb 27 '19 at 20:29
2

You don't need to uninstall the newest version of bundler (especially if you have other applications).

First find the bundler version that you need. For example, after running bundle install:

Could not find gem 'bundler (>= 1.3.0, < 2.0)', which is required by gem 'rails (~> 4.2)', in any of the sources.

I need any version between 1.3.0 and 2.0. Hence, I would go for bundler 1.9.

Then, install the bundler:

gem install bundler -v 1.9

Run that bundler version to install gems:

bundler _1.9_ install
B-M
  • 1,248
  • 9
  • 19