Skip to content
Browse files

Print better error during install when you need to relock

Closes #272
  • Loading branch information...
1 parent be5796e commit ef6a00f955da0359bdd63f31cec6699d74569cfc @indirect indirect committed Apr 11, 2010
Showing with 7 additions and 2 deletions.
  1. +1 −0 lib/bundler.rb
  2. +5 −1 lib/bundler/cli.rb
  3. +1 −1 lib/bundler/definition.rb
View
1 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
View
6 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?
View
2 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

0 comments on commit ef6a00f

Please sign in to comment.
Something went wrong with that request. Please try again.