From 1a693068398c84c113288882cc6458738932c069 Mon Sep 17 00:00:00 2001 From: Teemu Matilainen Date: Wed, 15 Jan 2014 19:15:49 -0300 Subject: [PATCH] core: Respect VAGRANT_HOME everywhere Use `VAGRANT_HOME`env var also for `Plugin::Manager` etc., not only in the `Environment` class. --- lib/vagrant/environment.rb | 2 +- lib/vagrant/shared_helpers.rb | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 2423e8d44..fcba1e292 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -599,7 +599,7 @@ module Vagrant # @return [Pathname] def setup_home_path @home_path = Util::Platform.fs_real_path( - @home_path || ENV["VAGRANT_HOME"] || Vagrant.user_data_path) + @home_path || Vagrant.user_data_path) @logger.info("Home path: #{@home_path}") # Setup the list of child directories that need to be created if they diff --git a/lib/vagrant/shared_helpers.rb b/lib/vagrant/shared_helpers.rb index 78cdb4a92..f1385987d 100644 --- a/lib/vagrant/shared_helpers.rb +++ b/lib/vagrant/shared_helpers.rb @@ -20,15 +20,19 @@ module Vagrant # # @return [Pathname] def self.user_data_path - path = "~/.vagrant.d" + # Use user spcified env var if available + path = ENV["VAGRANT_HOME"] # On Windows, we default ot the USERPROFILE directory if it # is available. This is more compatible with Cygwin and sharing # the home directory across shells. - if ENV["USERPROFILE"] + if !path && ENV["USERPROFILE"] path = "#{ENV["USERPROFILE"]}/.vagrant.d" end - return Pathname.new(path).expand_path + # Fallback to the default + path ||= "~/.vagrant.d" + + Pathname.new(path).expand_path end end