Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Information on what gem bundler has started to install, to ease debugging #1380

Merged
merged 3 commits into from

2 participants

Ryan Wilcox André Arko
Ryan Wilcox

When something goes wrong with a gem bundler currently gives output like this:

....

Installing somegem
Undefined some_method for NilClass

A user might believe that the problem happened when trying to install somegem, and blame the issue on bundler when "gem install somegem" is successful.

In fact, what has happened is Bundler has successfully installed somegem, but has failed on the next gem in the list. However, figuring out the next gem in the list is non-trivial for a non Bundler developer to figure out.

This pull outputs the following line before starting processing on the current gem.

Thus, the output from the failure above would look like:

  Currently processing 'somegem'...
Installing somegem

  Currently processing 'bad_gem'
Undefined some_method for NilClass

With this change a user can identify that 'bad_gem' is the gem with errors, and try to 'gem install bad_gem' (to see if the error is bundler specific, or something with the gem / Rubygems)

André Arko
Owner
Ryan Wilcox

I moved the debugging information into a rescue statement and pushed the commit to my branch. What do you think now?

lib/bundler/installer.rb
((25 lines not shown))
- Bundler.ui.info ""
- generate_bundler_executable_stubs(spec) if Bundler.settings[:bin]
- FileUtils.rm_rf(Bundler.tmp)
+ Bundler.ui.info ""
+ generate_bundler_executable_stubs(spec) if Bundler.settings[:bin]
+ FileUtils.rm_rf(Bundler.tmp)
+ rescue Exception
+ puts "Error: '#{$!.message}', when installing #{spec.name}"
André Arko Owner
indirect added a note

This should use the Bundler UI classes, maybe something more like

rescue => e
  Bundler.ui.warn "#{e.class}: #{e.message}"
  Bundler.ui.error "An error occurred while installing gem #{spec.name} (#{spec.version}), and Bundler cannot continue."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
André Arko
Owner

As soon as the error messaging is fixed, this looks good. Thanks!

Ryan Wilcox

Latest commit uses the UI methods, and has slightly better wording (based on your suggestions)!

Let me know if there's anything else I can do!

André Arko indirect merged commit 82ac6b6 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 19 additions and 12 deletions.
  1. +19 −12 lib/bundler/installer.rb
31 lib/bundler/installer.rb
View
@@ -47,21 +47,28 @@ def run(options)
# as dependencies might actually affect the installation of
# the gem.
specs.each do |spec|
- spec.source.fetch(spec) if spec.source.respond_to?(:fetch)
+ begin
+ spec.source.fetch(spec) if spec.source.respond_to?(:fetch)
- # unless requested_specs.include?(spec)
- # Bundler.ui.debug " * Not in requested group; skipping."
- # next
- # end
+ # unless requested_specs.include?(spec)
+ # Bundler.ui.debug " * Not in requested group; skipping."
+ # next
+ # end
- Bundler.rubygems.with_build_args [Bundler.settings["build.#{spec.name}"]] do
- spec.source.install(spec)
- Bundler.ui.debug "from #{spec.loaded_from} "
- end
+ Bundler.rubygems.with_build_args [Bundler.settings["build.#{spec.name}"]] do
+ spec.source.install(spec)
+ Bundler.ui.debug "from #{spec.loaded_from} "
+ end
- Bundler.ui.info ""
- generate_bundler_executable_stubs(spec) if Bundler.settings[:bin]
- FileUtils.rm_rf(Bundler.tmp)
+ Bundler.ui.info ""
+ generate_bundler_executable_stubs(spec) if Bundler.settings[:bin]
+ FileUtils.rm_rf(Bundler.tmp)
+ rescue Exception => e
+ Bundler.ui.warn "#{e.class}: #{e.message}"
+ Bundler.ui.error "An error (#{e.message}) occured while installing #{spec.name} (#{spec.version})"
+ Bundler.ui.error "Bundler can not continue. Try manually installing the gem, to determine if this is a Bundler specfic issue or issue with the gem itself"
+ raise
+ end
end
lock
Something went wrong with that request. Please try again.