From ef6a00f955da0359bdd63f31cec6699d74569cfc Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Sun, 11 Apr 2010 20:45:55 -0700 Subject: [PATCH] Print better error during install when you need to relock Closes #272 --- lib/bundler.rb | 1 + lib/bundler/cli.rb | 6 +++++- lib/bundler/definition.rb | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/bundler.rb b/lib/bundler.rb index dfda6481638..5b21968d1b2 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -38,6 +38,7 @@ class GemfileNotFound < BundlerError; status_code(10) ; end class GemNotFound < BundlerError; status_code(7) ; end class VersionConflict < BundlerError; status_code(6) ; end class GemfileError < BundlerError; status_code(4) ; end + class GemfileChanged < GemfileError; status_code(4) ; end class PathError < BundlerError; status_code(13) ; end class GitError < BundlerError; status_code(11) ; end class DeprecatedMethod < BundlerError; status_code(12) ; end diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 4f8259e49ff..0ef97049a54 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -85,7 +85,11 @@ def install(path = nil) remove_lockfiles if options[:relock] - Installer.install(Bundler.root, Bundler.definition, opts) + begin + Installer.install(Bundler.root, Bundler.definition, opts) + rescue GemfileChanged + raise GemfileChanged, "You changed your Gemfile after locking. Please run `bundle install --relock`." + end lock if options[:relock] cache if Bundler.root.join("vendor/cache").exist? diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 91d0c58ddf3..d1b9a93b54f 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -17,7 +17,7 @@ def self.from_lock(lockfile) hash = Digest::SHA1.hexdigest(File.read("#{Bundler.root}/Gemfile")) unless locked_definition.hash == hash - raise GemfileError, "You changed your Gemfile after locking. Please relock using `bundle lock`" + raise GemfileChanged, "You changed your Gemfile after locking. Please relock using `bundle lock`" end locked_definition