From 8f3dd06d8e3b6d3cd9aaf7b5c2ccd5825817326e Mon Sep 17 00:00:00 2001 From: Tim Brown Date: Mon, 11 Nov 2013 14:10:11 -0800 Subject: [PATCH] Use :SystemRoot to detect Windows, including git-bash. Also use :Windir to ensure we get correct hosts file path --- lib/vagrant-hostmanager/hosts_file.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/vagrant-hostmanager/hosts_file.rb b/lib/vagrant-hostmanager/hosts_file.rb index 5735ded..14602c3 100644 --- a/lib/vagrant-hostmanager/hosts_file.rb +++ b/lib/vagrant-hostmanager/hosts_file.rb @@ -10,7 +10,8 @@ module VagrantPlugins realhostfile = '/etc/inet/hosts' move_cmd = 'mv' elsif (machine.communicate.test("test -d $Env:SystemRoot")) - realhostfile = 'C:\Windows\System32\Drivers\etc\hosts' + realhostfile = "#{ENV['WINDIR']}\\System32\\drivers\\etc\\hosts" + move_cmd = 'mv -force' else realhostfile = '/etc/hosts' @@ -38,7 +39,7 @@ module VagrantPlugins hosts_location = '/etc/hosts' copy_cmd = 'sudo cp' # handles the windows hosts file... - if ENV['OS'] == 'Windows_NT' + if ENV['SystemRoot'] != nil hosts_location = "#{ENV['WINDIR']}\\System32\\drivers\\etc\\hosts" copy_cmd = 'cp' end