From 89eb256f9deee697cf15f8166cb59595489fef77 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 8 Jan 2012 11:29:52 -0800 Subject: [PATCH] Proper error handling if the shared folder cannot be created [GH-604] --- lib/vagrant/action/vm/share_folders.rb | 7 ++++++- lib/vagrant/errors.rb | 5 +++++ templates/locales/en.yml | 8 ++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/action/vm/share_folders.rb b/lib/vagrant/action/vm/share_folders.rb index 33807c9de..4e761baea 100644 --- a/lib/vagrant/action/vm/share_folders.rb +++ b/lib/vagrant/action/vm/share_folders.rb @@ -46,7 +46,12 @@ module Vagrant if !hostpath.directory? && options[:create] # Host path doesn't exist, so let's create it. @logger.debug("Host path doesn't exist, creating: #{hostpath}") - hostpath.mkpath + + begin + hostpath.mkpath + rescue Errno::EACCES + raise Errors::SharedFolderCreateFailed, :path => hostpath.to_s + end end end end diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index 429b9c7d5..45546a186 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -268,6 +268,11 @@ module Vagrant error_key(:scp_unavailable) end + class SharedFolderCreateFailed < VagrantError + status_code(66) + error_key(:shared_folder_create_failed) + end + class SSHAuthenticationFailed < VagrantError status_code(11) error_key(:ssh_authentication_failed) diff --git a/templates/locales/en.yml b/templates/locales/en.yml index b04a407f9..ff3b9840f 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -80,6 +80,14 @@ en: scp_unavailable: |- SSH server on the guest doesn't support SCP. Please install the necessary software to enable SCP on your guest operating system. + shared_folder_create_failed: |- + Failed to create the following shared folder on the host system. This is + usually because Vagrant does not have sufficient permissions to create + the folder. + + %{path} + + Please create the folder manually or specify another path to share. ssh_authentication_failed: |- SSH authentication failed! This is typically caused by the public/private keypair for the SSH user not being properly set on the guest VM. Please