Permalink
Browse files

Improve DSL, Gemfile, and command error messages

Closes #242
  • Loading branch information...
1 parent f231802 commit f03cc081e5d35d48cc97f9542b8ab8392b8fe11c @indirect indirect committed Apr 3, 2010
View
7 lib/bundler/cli.rb
@@ -52,14 +52,14 @@ def check
missing.each do |d|
Bundler.ui.error " * #{d}"
end
- Bundler.ui.error "Try running `bundle install`"
+ Bundler.ui.warn "Install missing gems with `bundle install`"
exit 1
else
not_installed = env.requested_specs.select { |spec| !spec.loaded_from }
if not_installed.any?
not_installed.each { |s| Bundler.ui.error "#{s.name} (#{s.version}) is cached, but not installed" }
- Bundler.ui.error "Try running `bundle install`"
+ Bundler.ui.warn "Install missing gems with `bundle install`"
exit 1
else
Bundler.ui.info "The Gemfile's dependencies are satisfied"
@@ -138,7 +138,7 @@ def cache
Bundler.runtime.cache
rescue GemNotFound => e
Bundler.ui.error(e.message)
- Bundler.ui.info "Run `bundle install` to install missing gems."
+ Bundler.ui.warn "Run `bundle install` to install missing gems."
exit 128
end
@@ -172,6 +172,7 @@ def exec(*)
Kernel.exec *ARGV
rescue Errno::ENOENT
Bundler.ui.error "bundler: command not found: #{ARGV.first}"
+ Bundler.ui.warn "Install missing gem binaries with `bundle install`"
end
end
View
23 lib/bundler/dsl.rb
@@ -64,13 +64,20 @@ def group(*args, &blk)
# Deprecated methods
- def self.deprecate(name)
+ def self.deprecate(name, replacement = nil)
define_method(name) do |*|
- raise DeprecatedMethod, "#{name} has been removed from the Gemfile DSL. See the README for more information on upgrading from Bundler 0.8."
+ message = "'#{name}' has been removed from the Gemfile DSL, "
+ if replacement
+ message << "and has been replaced with '#{replacement}'."
+ else
+ message << "and is no longer supported."
+ end
+ message << "\nSee the README for more information on upgrading from Bundler 0.8."
+ raise DeprecatedMethod, message
end
end
- deprecate :only
+ deprecate :only, :group
deprecate :except
deprecate :disable_system_gems
deprecate :disable_rubygems
@@ -101,9 +108,13 @@ def _normalize_options(name, version, opts)
invalid_keys = opts.keys - %w(group git path name branch ref tag require)
if invalid_keys.any?
plural = invalid_keys.size > 1
- raise InvalidOption, "You passed #{invalid_keys.join(", ")} " \
- "#{plural ? 'as options, but they are' : 'as an option, but it is'}" \
- " invalid"
+ message = "You passed #{invalid_keys.map{|k| ':'+k }.join(", ")} "
+ if plural
+ message << "as options for gem '#{name}', but they are invalid."
+ else
+ message << "as an option for gem '#{name}', but it is invalid."
+ end
+ raise InvalidOption, message
end
group = opts.delete("group") || @group
View
2 lib/bundler/runtime.rb
@@ -64,7 +64,7 @@ def lock
FileUtils.mkdir_p("#{root}/.bundle")
write_yml_lock
write_rb_lock
- Bundler.ui.info("The bundle is now locked. Use `bundle show` to list the gems in the environment.")
+ Bundler.ui.confirm("The bundle is now locked. Use `bundle show` to list the gems in the environment.")
end
def dependencies_for(*groups)
View
2 lib/bundler/shared_helpers.rb
@@ -16,7 +16,7 @@ module SharedHelpers
def default_gemfile
gemfile = find_gemfile
- gemfile or raise GemfileNotFound, "The default Gemfile was not found"
+ gemfile or raise GemfileNotFound, "Could not locate Gemfile"
Pathname.new(gemfile)
end
View
3 spec/install/deprecated_spec.rb
@@ -14,7 +14,8 @@
G
bundle :install
- out.should =~ /#{deprecated} is removed. See the README for more information/
+ out.should =~ /'#{deprecated}' has been removed/
+ out.should =~ /See the README for more information/
end
end
View
2 spec/install/invalid_spec.rb
@@ -11,7 +11,7 @@
G
bundle :install
- out.should =~ /You passed lib as an option, but it is invalid/
+ out.should =~ /You passed :lib as an option for gem 'rack', but it is invalid/
end
end
View
4 spec/other/check_spec.rb
@@ -86,10 +86,10 @@
@exitstatus.should == 1
end
- it "outputs an error when the default Gemspec is not found" do
+ it "outputs an error when the default Gemfile is not found" do
bundle :check, :exit_status => true
@exitstatus.should == 10
- out.should include("The default Gemfile was not found")
+ out.should include("Could not locate Gemfile")
end
describe "when locked" do
View
2 spec/runtime/load_spec.rb
@@ -29,7 +29,7 @@
it "raises an exception if the default gemfile is not found" do
lambda {
Bundler.load
- }.should raise_error(Bundler::GemfileNotFound, /default/)
+ }.should raise_error(Bundler::GemfileNotFound, /could not locate gemfile/i)
end
it "raises an exception if a specified gemfile is not found" do

0 comments on commit f03cc08

Please sign in to comment.