summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Arko <mail@arko.net>2015-05-04 19:15:26 -0700
committerAndré Arko <mail@arko.net>2015-05-04 19:15:26 -0700
commit8050cd6a41d94851a6a6fad2fdb29b9b534bc74c (patch)
tree320ebf442e293dea71aa073add93f092045c6b78
parentd8df35c18db3c300e8191d53eb06c6437876d948 (diff)
parent91b0e741c385ba1189521cb1d982588e834986de (diff)
downloadbundler-8050cd6a41d94851a6a6fad2fdb29b9b534bc74c.tar.gz
Merge pull request #3612 from bundler/seg-major-version-erros
Warn when upgrading lockfile major version & error when major version is...
-rw-r--r--lib/bundler/definition.rb10
-rw-r--r--lib/bundler/lockfile_parser.rb16
-rw-r--r--spec/install/bundler_spec.rb2
-rw-r--r--spec/lock/lockfile_spec.rb116
4 files changed, 136 insertions, 8 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index d8aab4fbb4..eb97b81a5d 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -249,6 +249,16 @@ module Bundler
return
end
+ if @locked_bundler_version
+ locked_major = @locked_bundler_version.segments.first
+ current_major = Gem::Version.create(Bundler::VERSION).segments.first
+
+ if locked_major < current_major
+ Bundler.ui.warn "Warning: the lockfile is being updated to Bundler #{Bundler::VERSION.split('.').first}, " \
+ "after which you will be unable to return to Bundler #{@locked_bundler_version.segments.first}."
+ end
+ end
+
File.open(file, 'wb'){|f| f.puts(contents) }
rescue Errno::EACCES
raise Bundler::InstallError,
diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb
index dcd966b9d8..21367fe70c 100644
--- a/lib/bundler/lockfile_parser.rb
+++ b/lib/bundler/lockfile_parser.rb
@@ -60,11 +60,17 @@ module Bundler
def warn_for_outdated_bundler_version
return unless bundler_version
prerelease_text = bundler_version.prerelease? ? " --pre" : ""
- if Gem::Version.new(Bundler::VERSION) < Gem::Version.new(bundler_version)
- Bundler.ui.warn "Warning: the running version of Bundler is older " \
- "than the version that created the lockfile. We suggest you " \
- "upgrade to the latest version of Bundler by running `gem " \
- "install bundler#{prerelease_text}`.\n"
+ current_version = Gem::Version.create(Bundler::VERSION)
+ case current_version.segments.first <=> bundler_version.segments.first
+ when -1
+ raise LockfileError, "You must use Bundler #{bundler_version.segments.first} or greater with this lockfile."
+ when 0
+ if current_version < bundler_version
+ Bundler.ui.warn "Warning: the running version of Bundler is older " \
+ "than the version that created the lockfile. We suggest you " \
+ "upgrade to the latest version of Bundler by running `gem " \
+ "install bundler#{prerelease_text}`.\n"
+ end
end
end
diff --git a/spec/install/bundler_spec.rb b/spec/install/bundler_spec.rb
index 066b9309c5..516581b7f3 100644
--- a/spec/install/bundler_spec.rb
+++ b/spec/install/bundler_spec.rb
@@ -139,7 +139,7 @@ describe "bundle install" do
#simulate_new_machine
bundle "check"
- expect(out).to eq("The Gemfile's dependencies are satisfied")
+ expect(out).to include("The Gemfile's dependencies are satisfied")
end
end
diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb
index ea712de21c..c5707227dd 100644
--- a/spec/lock/lockfile_spec.rb
+++ b/spec/lock/lockfile_spec.rb
@@ -129,6 +129,51 @@ describe "the lockfile format" do
rack
BUNDLED WITH
+ 9999999.1.0
+ L
+
+ simulate_bundler_version "9999999.0.0" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+ G
+ end
+
+ expect(out).to include("Warning: the running version of Bundler is " \
+ "older than the version that created the lockfile")
+
+ lockfile_should_be <<-G
+ GEM
+ remote: file:#{gem_repo1}/
+ specs:
+ rack (1.0.0)
+
+ PLATFORMS
+ #{generic(Gem::Platform.local)}
+
+ DEPENDENCIES
+ rack
+
+ BUNDLED WITH
+ 9999999.1.0
+ G
+ end
+
+ it "errors if the current is a major version older than lockfile's bundler version" do
+ lockfile <<-L
+ GEM
+ remote: file:#{gem_repo1}/
+ specs:
+ rack (1.0.0)
+
+ PLATFORMS
+ #{generic(Gem::Platform.local)}
+
+ DEPENDENCIES
+ rack
+
+ BUNDLED WITH
9999999.0.0
L
@@ -138,8 +183,75 @@ describe "the lockfile format" do
gem "rack"
G
- expect(out).to include("Warning: the running version of Bundler is " \
- "older than the version that created the lockfile")
+ 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(out).to include("You must use Bundler 9999999 or greater with this lockfile.")
+ end
+
+ it "warns when updating bundler major version" do
+ lockfile <<-L
+ GEM
+ remote: file:#{gem_repo1}/
+ specs:
+ rack (1.0.0)
+
+ PLATFORMS
+ #{generic(Gem::Platform.local)}
+
+ DEPENDENCIES
+ rack
+
+ BUNDLED WITH
+ 1.10.0
+ L
+
+ simulate_bundler_version "9999999.0.0" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+ G
+ end
+
+ expect(out).to include("Warning: the lockfile is being updated to Bundler " \
+ "9999999, after which you will be unable to return to Bundler 1.")
lockfile_should_be <<-G
GEM