How do I get the error message from bundler?


(Sam Saffron) #1

I am cleaning up error handling in pups and came across this:

FAILED
--------------------
RuntimeError: cd /var/www/discourse && su discourse -c 'bundle install --deployment --verbose --without test --without development' failed with return #<Process::Status: pid 213 exit 5>
Location of failure: /pups/lib/pups/exec_command.rb:85:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"web", "cmd"=>["gem update bundler", "chown -R discourse $home", "su discourse -c 'bundle install --deployment --verbose --without test --without development'", "su discourse -c 'bundle exec rake db:migrate'", "su discourse -c 'bundle exec rake assets:precompile'"]}
eb51bfe6e220a569db8682402df5fceaf6c5e12a10cf09bf906cc203e29290e3
FAILED TO BOOTSTRAP

This is correct, bundle install failed with a runtime error, however…

When you dig further up you see:

Errno::ENOSPC: No space left on device
/usr/local/lib/ruby/site_ruby/2.0.0/rubygems/package/tar_writer.rb:268:in `flush'
/usr/local/lib/ruby/site_ruby/2.0.0/rubygems/package/tar_writer.rb:268:in `flush'
/usr/local/lib/ruby/site_ruby/2.0.0/rubygems/package/tar_writer.rb:250:in `close'
/usr/local/lib/ruby/site_ruby/2.0.0/rubygems/package/tar_writer.rb:87:in `ensure in new'
/usr/local/lib/ruby/site_ruby/2.0.0/rubygems/package/tar_writer.rb:87:in `new'
/usr/local/lib/ruby/site_ruby/2.0.0/rubygems/package.rb:241:in `block in build'
/usr/local/lib/ruby/2.0.0/open-uri.rb:36:in `open'
/usr/local/lib/ruby/2.0.0/open-uri.rb:36:in `open'
/usr/local/lib/ruby/site_ruby/2.0.0/rubygems/package/file_source.rb:25:in `with_write_io'
/usr/local/lib/ruby/site_ruby/2.0.0/rubygems/package.rb:240:in `build'
/usr/local/lib/ruby/site_ruby/2.0.0/rubygems/package.rb:114:in `build'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/rubygems_integration.rb:549:in `build'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/rubygems_integration.rb:196:in `block in build_gem'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/shared_helpers.rb:52:in `chdir'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/shared_helpers.rb:52:in `chdir'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/rubygems_integration.rb:196:in `build_gem'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/source/path.rb:184:in `generate_bin'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/source/path.rb:73:in `install'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/installer.rb:104:in `block in install_gem_from_spec'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/rubygems_integration.rb:162:in `with_build_args'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/installer.rb:103:in `install_gem_from_spec'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/installer.rb:261:in `block in install_sequentially'
/usr/local/lib/ruby/2.0.0/forwardable.rb:171:in `each'
/usr/local/lib/ruby/2.0.0/forwardable.rb:171:in `each'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/installer.rb:260:in `install_sequentially'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/installer.rb:90:in `run'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/installer.rb:18:in `install'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/cli/install.rb:78:in `run'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/cli.rb:145:in `install'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/vendor/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/vendor/thor/invocation.rb:121:in `invoke_command'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/vendor/thor.rb:363:in `dispatch'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/vendor/thor/base.rb:440:in `start'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/cli.rb:9:in `start'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/bin/bundle:20:in `block in <top (required)>'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/lib/bundler/friendly_errors.rb:5:in `with_friendly_errors'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.7.0/bin/bundle:18:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
An error occurred while installing rails_multisite (0.0.1), and Bundler cannot
continue.
Make sure that `gem install rails_multisite -v '0.0.1'` succeeds before
bundling.

The real reason this failed was cause we were out of disk space.

  • Is there any way to get bundle install to omit the huge stack trace?
  • How can I get the actual failure message out of bundler in a automated way … ideally I would like STDERR to simply have “Errno::ENOSPC: No space left in device”, then I can send that further down to pups.

(note asking here cause this does not fit in a tweet)


(Jens Maier) #2

This may be a stab at the dark, but… wrap Bundler::CLI#install in a method that rescues Bundler::InstallError. In Ruby 2.1, the original exception should be available v via e.cause.

Or instead of monkey-patching Bundler, provide your own bundler binary.

real_stderr = $stderr
$stderr = $stdout
require 'bundler'
require 'bundler/cli'
begin
  Bundler::CLI.start(['install'])
rescue => e
  real_stderr.puts e.cause.message
  exit 1
end


(Kane York) #3

This seems promising to me. Maybe call it bundlew.


(Sam Saffron) #4

FYI I repackage a little bundler shell, that said this is a legit bundler bug which I raised.

https://github.com/bundler/bundler/issues/3153


(Sam Saffron) #5

FYI this is now fixed in bundler Huge backtrace when out of space · Issue #3153 · bundler/bundler · GitHub


(Zlatibor Veljkovic) #6

For anyone having problems installing discourse with the error below

Errno::EACCES: Permission denied @ rb_sysopen - rails_multisite-0.0.1.gem
An error occurred while installing rails_multisite (0.0.1), and Bundler cannot continue.
Make sure that `gem install rails_multisite -v '0.0.1'` succeeds before bundling.

please check that /path/to/discourse/vendor/gems is owned by current user. It will be nice to point this out in the install docs…