2

RVM is set on ruby-2.4.0 & I created new application which have version,

gem 'rails', '4.2.6'

I updated bundler using,

gem update --system
gem install bundler
bundle version
# Bundler version 2.0.1 (2019-01-04 commit d7ad2192f)

But I am getting following error while bundle install,

Fetching gem metadata from https://rubygems.org/.............
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Bundler could not find compatible versions for gem "bundler":
  In Gemfile:
    rails (= 4.2.6) was resolved to 4.2.6, 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.2.6)', in any of the sources.

It is asking me for lower version version of bundler required, why? How should I solve above?

ray
  • 5,454
  • 1
  • 18
  • 40

2 Answers2

11

Install any bundler with version (< 2.0, >= 1.3.0).

For example

gem install bundler -v 1.17.3

And then

bundle _1.17.3_ install

It should work for your situation.

mechnicov
  • 12,025
  • 4
  • 33
  • 56
  • 1
    removing `Gemfile.lock` is a bad idea, because information about gem versions will be lost and can cause unexpected things to happen. – dubadub Apr 04 '19 at 08:43
2

Your Gemfile specifies older bundler version which is not compatible with 2.x.x. Try to run gem install bundler -v 1.3.0 or whatever version you have listed in your Gemfile.lock (check the very end of file).

dubadub
  • 3,312
  • 3
  • 23
  • 28
  • Installed old version but showing 2.0.1 for `bundle --version` – ray Apr 03 '19 at 15:25
  • okay, you probably need to remove the newer bundler first `gem uninstall bundler --version 2.0.1` – dubadub Apr 03 '19 at 16:26
  • Yup, followed same and worked, easy but got difficult as never tried before! thanks:) – ray Apr 04 '19 at 06:22
  • In `Gemfile.lock` file the bundler version was 2.0.1 for me, I changed that into `1.16.1` as my project really needed that. Do `bundle install` It works! – Abhi Feb 20 '20 at 11:29