Ensure relative path for file provisioner is relative to machines cwd

Prior to this commit, if you ran Vagrant in a different current working
directory other than where a current guest machines location is, the
file provisioner would not take into account the machines local dir, and
would instead use the path where Vagrant was invoked to expand the
`source` path option for a file provisioner. This commit fixes that by
passing the root path `machine.env.cwd` when expanding the source dir.
This commit is contained in:
Brian Cain 2019-10-02 15:33:23 -07:00
parent 620500c1b0
commit 0a6c4e2d0f
No known key found for this signature in database
GPG Key ID: 9FC4639B2E4510A0
2 changed files with 2 additions and 2 deletions

View File

@ -3,7 +3,7 @@ module VagrantPlugins
class Provisioner < Vagrant.plugin("2", :provisioner)
def provision
@machine.communicate.tap do |comm|
source = File.expand_path(config.source)
source = File.expand_path(config.source, @machine.env.cwd)
destination = expand_guest_path(config.destination)
# If the source is a directory determine if any path modifications

View File

@ -65,7 +65,7 @@ describe VagrantPlugins::FileUpload::Provisioner do
allow(config).to receive(:destination).and_return("/foo/bar")
expect(communicator).to receive(:upload).with(
File.expand_path("source"), "/foo/bar")
File.expand_path("#{machine.env.cwd}/source"), "/foo/bar")
subject.provision
end