diff --git a/lib/vagrant/actions/vm/shared_folders.rb b/lib/vagrant/actions/vm/shared_folders.rb index 994d9dfc1..23c47f35d 100644 --- a/lib/vagrant/actions/vm/shared_folders.rb +++ b/lib/vagrant/actions/vm/shared_folders.rb @@ -31,14 +31,16 @@ module Vagrant end def clear_shared_folders - logger.info "Clearing previously set shared folders..." + if runner.vm.shared_folders.length > 0 + logger.info "Clearing previously set shared folders..." - folders = @runner.vm.shared_folders.dup - folders.each do |shared_folder| - shared_folder.destroy + folders = @runner.vm.shared_folders.dup + folders.each do |shared_folder| + shared_folder.destroy + end + + @runner.reload! end - - @runner.reload! end def create_metadata diff --git a/test/vagrant/actions/vm/shared_folders_test.rb b/test/vagrant/actions/vm/shared_folders_test.rb index f9490b5e3..e30a09a77 100644 --- a/test/vagrant/actions/vm/shared_folders_test.rb +++ b/test/vagrant/actions/vm/shared_folders_test.rb @@ -81,6 +81,12 @@ class SharedFoldersActionTest < Test::Unit::TestCase @runner.expects(:reload!).once.in_sequence(destroy_seq) @action.clear_shared_folders end + + should "do nothing if no shared folders existed" do + @shared_folders.clear + @runner.expects(:reload!).never + @action.clear_shared_folders + end end context "setting up shared folder metadata" do