Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't alter the path during the bundler cleanup on windows #241

Merged
merged 1 commit into from
Dec 5, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions lib/kitchen/driver/vagrant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ def run(cmd, options = {})
# will inherit our bundled environment.
# @see https://github.com/test-kitchen/kitchen-vagrant/issues/190
# @see Kitchen::ShellOut#run_command
# rubocop:disable Metrics/CyclomaticComplexity
def run_command(cmd, options = {})
merged = {
:use_sudo => config[:use_sudo],
Expand All @@ -359,15 +360,27 @@ def run_command(cmd, options = {})
RUBYOPT _ORIGINAL_GEM_PATH].each do |var|
env[var] = nil
end
gem_home = ENV["GEM_HOME"]
if gem_home && (env["PATH"] || ENV["PATH"])
env["PATH"] ||= ENV["PATH"].dup if ENV["PATH"]
gem_bin = File.join(gem_home, "bin") + File::PATH_SEPARATOR
env["PATH"][gem_bin] = "" if env["PATH"].include?(gem_bin)

# Altering the path seems to break vagrant. When the :environment
# is passed to a windows process with a PATH, Vagrant's batch installer
# (https://github.com/mitchellh/vagrant-installers/blob/master/substrate
# /modules/vagrant_installer/templates/windows_vagrant.bat.erb)
# does not efectively prepend the vagrant ruby path in a persistent
# manner which causes vagrant to use the same ruby as test-kitchen and
# then the environment is essentially corrupted leading to many errors
# and dispair
unless windows_host?
gem_home = ENV["GEM_HOME"]
if gem_home && (env["PATH"] || ENV["PATH"])
env["PATH"] ||= ENV["PATH"].dup if ENV["PATH"]
gem_bin = File.join(gem_home, "bin") + File::PATH_SEPARATOR
env["PATH"][gem_bin] = "" if env["PATH"].include?(gem_bin)
end
end

super(cmd, merged)
end
# rubocop:enable Metrics/CyclomaticComplexity

# Runs a local command before `vagrant up` has been called.
#
Expand Down Expand Up @@ -477,6 +490,13 @@ def verify_winrm_plugin
end
end

# @return [true,false] whether or not the host is windows
#
# @api private
def windows_host?
RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
end

# @return [true,false] whether or not the vagrant-winrm plugin is
# installed
# @api private
Expand Down