From c1373f4eca603f7830b366d9f1a76f9d4b670364 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 8 Feb 2011 22:47:36 -0800 Subject: [PATCH] Failed SSH commands show output in error message. [closes GH-285] --- CHANGELOG.md | 1 + lib/vagrant/ssh/session.rb | 8 +++++--- templates/locales/en.yml | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2bfb06d28e..4d8cfb4bf5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Change sudo shell to use `bash` (configurable). [GH-301] - Can now set mac address of host only network. [GH-294] - NFS shared folders with spaces now work properly. [GH-293] + - Failed SSH commands now show output in error message. [GH-285] ## 0.7.1 (January 28, 2011) diff --git a/lib/vagrant/ssh/session.rb b/lib/vagrant/ssh/session.rb index 311218b15b5..ea62906fda0 100644 --- a/lib/vagrant/ssh/session.rb +++ b/lib/vagrant/ssh/session.rb @@ -75,7 +75,7 @@ def setup_channel_callbacks(channel, command, options, block) options = { :error_check => true }.merge(options || {}) block ||= Proc.new do |ch, type, data| - check_exit_status(data, command, options) if type == :exit_status && options[:error_check] + check_exit_status(data, command, options, ch[:result]) if type == :exit_status && options[:error_check] ch[:result] ||= "" ch[:result] << data if [:stdout, :stderr].include?(type) @@ -99,12 +99,14 @@ def setup_channel_callbacks(channel, command, options, block) # Checks for an erroroneous exit status and raises an exception # if so. - def check_exit_status(exit_status, commands, options=nil) + def check_exit_status(exit_status, commands, options=nil, output=nil) if exit_status != 0 + output ||= '[no output]' options = { :_error_class => Errors::VagrantError, :_key => :ssh_bad_exit_status, - :command => [commands].flatten.join("\n") + :command => [commands].flatten.join("\n"), + :output => output }.merge(options || {}) raise options[:_error_class], options diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 935a3375eda..d6ae4403b18 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -70,6 +70,10 @@ en: Vagrant assumes that this means the command failed! %{command} + + The output of the command prior to failing is outputted below: + + %{output} ssh_connection_refused: |- SSH connection was refused! This usually happens if the VM failed to boot properly. Some steps to try to fix this: First, try reloading your