Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Print better error during install when you need to relock
Browse files Browse the repository at this point in the history
Closes #272
  • Loading branch information
indirect committed Apr 12, 2010
1 parent be5796e commit ef6a00f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion lib/bundler/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ef6a00f

Please sign in to comment.