From d8e959c89fcecbc966cfa983e9f8fd54a23edd8a Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 17 Dec 2021 17:12:51 -0800 Subject: [PATCH] Connect synced folder to client in _initialize method --- lib/vagrant/plugin/remote/synced_folder.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/plugin/remote/synced_folder.rb b/lib/vagrant/plugin/remote/synced_folder.rb index 7290e67ce..645145ab4 100644 --- a/lib/vagrant/plugin/remote/synced_folder.rb +++ b/lib/vagrant/plugin/remote/synced_folder.rb @@ -13,7 +13,7 @@ module Vagrant end end - def initialize(client:) + def initialize(client: nil) @client = client @logger = Log4r::Logger.new("vagrant::remote::synced_folder::#{self.class.name}") if client.nil? @@ -22,6 +22,17 @@ module Vagrant end def _initialize(machine, synced_folder_type, client=nil) + if client.nil? + info = Thread.current.thread_variable_get(:service_info) + if info&.plugin_manager + @client = info.plugin_manager.get_plugin( + name: synced_folder_type, + type: :synced_folder, + ) + else + raise "Cannot set remote client for synced folder, no manager available" + end + end self end