From f5e38a4a14daa7e2c792592913ea650237cb2dd8 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 6 Jul 2015 14:58:48 -0600 Subject: [PATCH] kernel/v2: not an error if synced folder guest path is empty [GH-4833] --- plugins/kernel_v2/config/vm.rb | 18 ++++++++++-------- test/unit/plugins/kernel_v2/config/vm_test.rb | 6 ++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 9f41ce184..d71dd0c17 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -603,16 +603,18 @@ module VagrantPlugins guestpath = Pathname.new(options[:guestpath]) hostpath = Pathname.new(options[:hostpath]).expand_path(machine.env.root_path) - if guestpath.relative? && guestpath.to_s !~ /^\w+:/ - errors << I18n.t("vagrant.config.vm.shared_folder_guestpath_relative", - path: options[:guestpath]) - else - if used_guest_paths.include?(options[:guestpath]) - errors << I18n.t("vagrant.config.vm.shared_folder_guestpath_duplicate", + if guestpath.to_s != "" + if guestpath.relative? && guestpath.to_s !~ /^\w+:/ + errors << I18n.t("vagrant.config.vm.shared_folder_guestpath_relative", path: options[:guestpath]) - end + else + if used_guest_paths.include?(options[:guestpath]) + errors << I18n.t("vagrant.config.vm.shared_folder_guestpath_duplicate", + path: options[:guestpath]) + end - used_guest_paths.add(options[:guestpath]) + used_guest_paths.add(options[:guestpath]) + end end if !hostpath.directory? && !options[:create] diff --git a/test/unit/plugins/kernel_v2/config/vm_test.rb b/test/unit/plugins/kernel_v2/config/vm_test.rb index 50f185c9c..3d9b01213 100644 --- a/test/unit/plugins/kernel_v2/config/vm_test.rb +++ b/test/unit/plugins/kernel_v2/config/vm_test.rb @@ -480,6 +480,12 @@ describe VagrantPlugins::Kernel_V2::VMConfig do expect(sf["/vagrant"][:disabled]).to be_false expect(sf["/vagrant"][:foo]).to eq(:bar) end + + it "is not an error if guest path is empty" do + subject.synced_folder(".", "") + subject.finalize! + assert_valid + end end describe "#usable_port_range" do