From b52958bfb65e0d3fdb652dfa3d9d75ab91f6dc4c Mon Sep 17 00:00:00 2001 From: Teemu Matilainen Date: Sat, 1 Feb 2014 01:23:09 -0300 Subject: [PATCH] provisioners/file: expand destination path if capable --- plugins/provisioners/file/provisioner.rb | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/provisioners/file/provisioner.rb b/plugins/provisioners/file/provisioner.rb index 237e32043..7b997a7dc 100644 --- a/plugins/provisioners/file/provisioner.rb +++ b/plugins/provisioners/file/provisioner.rb @@ -3,12 +3,25 @@ module VagrantPlugins class Provisioner < Vagrant.plugin("2", :provisioner) def provision @machine.communicate.tap do |comm| + destination = expand_guest_path(config.destination) + # Make sure the remote path exists - command = "mkdir -p %s" % File.dirname(config.destination) - comm.execute(command) + command = "mkdir -p %s" % File.dirname(destination) + comm.execute(command) # now upload the file - comm.upload(File.expand_path(config.source), config.destination) + comm.upload(File.expand_path(config.source), destination) + end + end + + private + + # Expand the guest path if the guest has the capability + def expand_guest_path(destination) + if machine.guest.capability?(:shell_expand_guest_path) + machine.guest.capability(:shell_expand_guest_path, destination) + else + destination end end end