diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb index 87e2f2c2e49..6258e09e89c 100644 --- a/lib/bundler/lockfile_parser.rb +++ b/lib/bundler/lockfile_parser.rb @@ -103,7 +103,7 @@ def warn_for_outdated_bundler_version current_version = Gem::Version.create(Bundler::VERSION) current_major_version = current_version.segments.first major_bundler_version = bundler_version.segments.first - if current_major_version < major_bundler_version + if current_major_version < major_bundler_version && current_major_version > 2 raise LockfileError, "You must use Bundler #{major_bundler_version} or greater with this lockfile." end return unless current_version < bundler_version diff --git a/spec/lock/lockfile_bundler_1_spec.rb b/spec/lock/lockfile_bundler_1_spec.rb index d44b076cb73..d9fd9d38f78 100644 --- a/spec/lock/lockfile_bundler_1_spec.rb +++ b/spec/lock/lockfile_bundler_1_spec.rb @@ -203,7 +203,7 @@ G end - it "errors if the current is a major version older than lockfile's bundler version" do + it "warns if the current is a major version older than lockfile's bundler version" do lockfile <<-L GEM remote: file://localhost#{gem_repo1}/ @@ -227,45 +227,11 @@ G expect(exitstatus > 0) if exitstatus - expect(out).to include("You must use Bundler 9999999 or greater with this lockfile.") - end - - it "shows a friendly error when running with a new bundler 2 lockfile" do - lockfile <<-L - GEM - remote: https://rails-assets.org/ - specs: - rails-assets-bootstrap (3.3.4) - rails-assets-jquery (>= 1.9.1) - rails-assets-jquery (2.1.4) - - GEM - remote: https://rubygems.org/ - specs: - rake (10.4.2) - - PLATFORMS - ruby - - DEPENDENCIES - rails-assets-bootstrap! - rake - - BUNDLED WITH - 9999999.0.0 - L - - install_gemfile <<-G - source 'https://rubygems.org' - gem 'rake' - - source 'https://rails-assets.org' do - gem 'rails-assets-bootstrap' - end - G - - expect(exitstatus > 0) if exitstatus - expect(err).to include("You must use Bundler 9999999 or greater with this lockfile.") + warning_message = "the running version of Bundler (#{Bundler::VERSION}) is older " \ + "than the version that created the lockfile (9999999.0.0). " \ + "We suggest you to upgrade to the version that created the " \ + "lockfile by running `gem install bundler:9999999.0.0`." + expect(err).to include warning_message end it "warns when updating bundler major version" do diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb index d56cec7d787..b5e56cd675d 100644 --- a/spec/lock/lockfile_spec.rb +++ b/spec/lock/lockfile_spec.rb @@ -154,7 +154,7 @@ G end - it "outputs a warning if the current is older than lockfile's bundler version" do + it "outputs a warning if the current major is higher than 2 and older than lockfile's bundler version" do lockfile <<-L GEM remote: file://localhost#{gem_repo1}/ @@ -202,7 +202,7 @@ G end - it "errors if the current is a major version older than lockfile's bundler version" do + it "warns if the current major version is not higher that 2 and older than lockfile's bundler version" do lockfile <<-L GEM remote: file://localhost#{gem_repo1}/ @@ -225,11 +225,43 @@ gem "rack" G + warning_message = "the running version of Bundler (#{Bundler::VERSION}) is older " \ + "than the version that created the lockfile (9999999.0.0). " \ + "We suggest you to upgrade to the version that created the " \ + "lockfile by running `gem install bundler:9999999.0.0`." + expect(err).to include warning_message + end + + it "errors if the current major version is higher that 2 and older than lockfile's bundler version" do + lockfile <<-L + GEM + remote: file://localhost#{gem_repo1}/ + specs: + rack (1.0.0) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + rack + + BUNDLED WITH + 9999999.0.0 + L + + simulate_bundler_version "3.0.0" do + install_gemfile <<-G + source "file://localhost#{gem_repo1}/" + + gem "rack" + G + end + expect(last_command).to be_failure expect(err).to include("You must use Bundler 9999999 or greater with this lockfile.") end - it "shows a friendly error when running with a new bundler 2 lockfile" do + it "shows a friendly error when running with a new bundler 3 lockfile" do lockfile <<-L GEM remote: https://rails-assets.org/ @@ -254,14 +286,16 @@ 9999999.0.0 L - install_gemfile <<-G - source 'https://rubygems.org' - gem 'rake' + simulate_bundler_version "3.0.0" do + install_gemfile <<-G + source 'https://rubygems.org' + gem 'rake' - source 'https://rails-assets.org' do - gem 'rails-assets-bootstrap' - end - G + source 'https://rails-assets.org' do + gem 'rails-assets-bootstrap' + end + G + end expect(last_command).to be_failure expect(err).to include("You must use Bundler 9999999 or greater with this lockfile.")