diff options
author | Andre Arko <andre@arko.net> | 2011-09-13 15:30:12 -0700 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2011-09-13 15:30:12 -0700 |
commit | 7c5e5456ee819c1d4dae0382b9ae05921d7319c3 (patch) | |
tree | 02a1765575ade8c24088c5d970756696cb493b4f | |
parent | 86c7fb77634341665dead68bd2f52b1209cbf691 (diff) | |
download | bundler-7c5e5456ee819c1d4dae0382b9ae05921d7319c3.tar.gz |
Better gem install failure error, no backtrace
-rw-r--r-- | lib/bundler.rb | 3 | ||||
-rw-r--r-- | lib/bundler/installer.rb | 47 |
2 files changed, 27 insertions, 23 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb index 9b31b597f7..70c9328270 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -37,7 +37,7 @@ module Bundler autoload :UI, 'bundler/ui' class BundlerError < StandardError - def self.status_code(code = nil) + def self.status_code(code) define_method(:status_code) { code } end end @@ -45,6 +45,7 @@ module Bundler class GemfileNotFound < BundlerError; status_code(10) ; end class GemNotFound < BundlerError; status_code(7) ; end class GemfileError < BundlerError; status_code(4) ; end + class InstallError < BundlerError; status_code(5) ; end class PathError < BundlerError; status_code(13) ; end class GitError < BundlerError; status_code(11) ; end class DeprecatedError < BundlerError; status_code(12) ; end diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index f672584cf2..3ffd6901b6 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -47,28 +47,7 @@ module Bundler # as dependencies might actually affect the installation of # the gem. specs.each do |spec| - 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 - - 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) - 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 + install_gem_from_spec(spec) end lock @@ -76,6 +55,30 @@ module Bundler private + def install_gem_from_spec(spec) + # Download the gem to get the spec, because some specs that are returned + # by rubygems.org are broken and wrong. + spec.source.fetch(spec) if spec.source.respond_to?(:fetch) + + # Fetch the build settings, if there are any + settings = Bundler.settings["build.#{spec.name}"] + Bundler.rubygems.with_build_args [settings] do + spec.source.install(spec) + Bundler.ui.debug "from #{spec.loaded_from} " + end + + # newline after installing, some gems say "with native extensions" + 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}" + msg = "An error occured while installing #{spec.name} (#{spec.version})," + msg << " and Bundler cannot continue.\nMake sure that `gem install" + msg << " #{spec.name} -v '#{spec.version}'` succeeds before bundling." + raise Bundler::InstallError, msg + end + def generate_bundler_executable_stubs(spec) bin_path = Bundler.bin_path template = File.read(File.expand_path('../templates/Executable', __FILE__)) |