Allow VAGRANT_DOTFILE_PATH to be expanded as expected.
This allows custom paths that include special characters like `~` to be properly expanded instead of resulting in joined root path with special characters included.
This commit is contained in:
parent
159fca9d13
commit
832c62f2aa
|
@ -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
|
||||
|
|
|
@ -1023,6 +1023,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|
|
||||
|
|
Loading…
Reference in New Issue