summaryrefslogtreecommitdiff
path: root/lib/bundler/lockfile_parser.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bundler/lockfile_parser.rb')
-rw-r--r--lib/bundler/lockfile_parser.rb17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb
index dcd966b9d8..1c241b7a5a 100644
--- a/lib/bundler/lockfile_parser.rb
+++ b/lib/bundler/lockfile_parser.rb
@@ -60,11 +60,18 @@ 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"
+ locked_version = Gem::Version.create(bundler_version)
+ current_version = Gem::Version.create(Bundler::VERSION)
+ case current_version.segments.first <=> locked_version.segments.first
+ when -1
+ raise LockfileError, "You must use Bundler #{locked_version.segments.first} or greater with this lockfile."
+ when 0
+ if current_version < locked_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