diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index c7a1e6024..13481ef15 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -184,9 +184,11 @@ module VagrantPlugins end options ||= {} - options = options.dup options[:guestpath] = guestpath.to_s.gsub(/\/$/, '') options[:hostpath] = hostpath + options = (@__synced_folders[options[:guestpath]] || {}). + merge(options.dup) + # Make sure the type is a symbol options[:type] = options[:type].to_sym if options[:type] diff --git a/test/unit/plugins/kernel_v2/config/vm_test.rb b/test/unit/plugins/kernel_v2/config/vm_test.rb index f2e797cdd..50aa9dde1 100644 --- a/test/unit/plugins/kernel_v2/config/vm_test.rb +++ b/test/unit/plugins/kernel_v2/config/vm_test.rb @@ -410,6 +410,17 @@ describe VagrantPlugins::Kernel_V2::VMConfig do expect(sf).to have_key("/vagrant") expect(sf["/vagrant"][:disabled]).to be_true end + + it "allows overriding previously set options" do + subject.synced_folder(".", "/vagrant", disabled: true) + subject.synced_folder(".", "/vagrant", foo: :bar) + subject.finalize! + sf = subject.synced_folders + expect(sf.length).to eq(1) + expect(sf).to have_key("/vagrant") + expect(sf["/vagrant"][:disabled]).to be_true + expect(sf["/vagrant"][:foo]).to eq(:bar) + end end describe "#usable_port_range" do