From 218b697d5e1b1607a3cf88f097d94e882d2706a2 Mon Sep 17 00:00:00 2001 From: Carlos Rodrigues Date: Sun, 24 Jul 2016 19:01:54 +0100 Subject: [PATCH] This looks cleaner --- lib/vagrant/environment.rb | 9 ++++++--- .../source/docs/other/environmental-variables.html.md | 2 -- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 1af6d96d0..5f936c0fe 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -159,10 +159,13 @@ module Vagrant # Setup the local data directory. If a configuration path is given, # it is expanded relative to the root path. Otherwise, we use the # default (which is also expanded relative to the root path). - if ENV.has_key?("VAGRANT_DOTFILE_PATH") && !opts[:child] - opts[:local_data_path] ||= root_path.join(ENV["VAGRANT_DOTFILE_PATH"]) if !root_path.nil? + if !root_path.nil? + if !(ENV["VAGRANT_DOTFILE_PATH"] or "").empty? && !opts[:child] + opts[:local_data_path] ||= root_path.join(ENV["VAGRANT_DOTFILE_PATH"]) + else + opts[:local_data_path] ||= root_path.join(DEFAULT_LOCAL_DATA) + end end - opts[:local_data_path] ||= root_path.join(DEFAULT_LOCAL_DATA) if !root_path.nil? if opts[:local_data_path] @local_data_path = Pathname.new(File.expand_path(opts[:local_data_path], @cwd)) end diff --git a/website/source/docs/other/environmental-variables.html.md b/website/source/docs/other/environmental-variables.html.md index fe21e6451..0f827267d 100644 --- a/website/source/docs/other/environmental-variables.html.md +++ b/website/source/docs/other/environmental-variables.html.md @@ -68,8 +68,6 @@ a scripting environment in order to set the directory that Vagrant sees. `VAGRANT_DOTFILE_PATH` can be set to change the directory where Vagrant stores VM-specific state, such as the VirtualBox VM UUID. By default, this is set to `.vagrant`. If you keep your Vagrantfile in a Dropbox folder in order to share the folder between your desktop and laptop (for example), Vagrant will overwrite the files in this directory with the details of the VM on the most recently-used host. To avoid this, you could set `VAGRANT_DOTFILE_PATH` to `.vagrant-laptop` and `.vagrant-desktop` on the respective machines. (Remember to update your `.gitignore`!) -Non-absolute paths in this environmental variable are interpreted as relative to the Vagrantfile's location. - ## `VAGRANT_HOME` `VAGRANT_HOME` can be set to change the directory where Vagrant stores