From 0a5d37fc8b56a8bd7834dd667d8bf025ff2a76ff Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Thu, 9 Jul 2015 13:52:27 -0600 Subject: [PATCH] Reset the original environment if we are running something outside of the installer --- lib/vagrant/util/subprocess.rb | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/vagrant/util/subprocess.rb b/lib/vagrant/util/subprocess.rb index e610151d2..fc574e7cf 100644 --- a/lib/vagrant/util/subprocess.rb +++ b/lib/vagrant/util/subprocess.rb @@ -72,6 +72,15 @@ module Vagrant process.io.stderr = stderr_writer process.duplex = true + # Reset the Bundler environment back - this is required for anyone who + # is not using the official Vagrant installers and is running Vagrant + # via bundler + if defined?(Bundler::ORIGINAL_ENV) + Bundler::ORIGINAL_ENV.each do |k, v| + process.environment[k] = v + end + end + # If we're in an installer on Mac and we're executing a command # in the installer context, then force DYLD_LIBRARY_PATH to look # at our libs first. @@ -89,14 +98,15 @@ module Vagrant @logger.info("Command is setuid/setgid, clearing DYLD_LIBRARY_PATH") process.environment["DYLD_LIBRARY_PATH"] = "" end - end - # Reset the Bundler environment back - this is required for anyone who - # is not using the official Vagrant installers and is running Vagrant - # via bundler - if defined?(Bundler::ORIGINAL_ENV) - Bundler::ORIGINAL_ENV.each do |k, v| - process.environment[k] = v + # If the command that is being run is not inside the installer, reset + # the original environment - this is required for shelling out to + # other subprocesses that depend on environment variables (like Ruby + # and $GEM_PATH for example) + if !command[0].include?(installer_dir) + Vagrant.original_env.each do |k, v| + process.environemnt[k] = v + end end end