Merge pull request #8196 from chrisroberts/fix/expand-vagrantfile-path

Allow VAGRANT_DOTFILE_PATH to be expanded as expected.
This commit is contained in:
Chris Roberts 2017-02-23 13:33:07 -08:00 committed by GitHub
commit 74438cc495
2 changed files with 12 additions and 2 deletions

View File

@ -160,8 +160,8 @@ module Vagrant
# it is expanded relative to the root path. Otherwise, we use the
# default (which is also expanded relative to the root path).
if !root_path.nil?
if !(ENV["VAGRANT_DOTFILE_PATH"] or "").empty? && !opts[:child]
opts[:local_data_path] ||= root_path.join(ENV["VAGRANT_DOTFILE_PATH"])
if !ENV["VAGRANT_DOTFILE_PATH"].to_s.empty? && !opts[:child]
opts[:local_data_path] ||= Pathname.new(File.expand_path(ENV["VAGRANT_DOTFILE_PATH"], root_path))
else
opts[:local_data_path] ||= root_path.join(DEFAULT_LOCAL_DATA)
end

View File

@ -1030,6 +1030,16 @@ VF
end
end
context "with environmental variable VAGRANT_DOTFILE_PATH set with tilde" do
it "is set relative to the user's home directory" do
with_temp_env("VAGRANT_DOTFILE_PATH" => "~/.vagrant") do
instance = env.create_vagrant_env
expect(instance.cwd).to eq(env.workdir)
expect(instance.local_data_path.to_s).to eq(File.join(Dir.home, ".vagrant"))
end
end
end
describe "upgrading V1 dotfiles" do
let(:v1_dotfile_tempfile) do
Tempfile.new("vagrant-upgrade-dotfile").tap do |f|