From e59ec19a03dced5b9de805a9b3002d47bfe2b97a Mon Sep 17 00:00:00 2001 From: Matthew Hopkins Date: Wed, 29 Jan 2014 16:10:10 -0500 Subject: [PATCH 1/2] Fix for windows guests running on non-windows hosts. --- lib/vagrant-hostmanager/hosts_file.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/vagrant-hostmanager/hosts_file.rb b/lib/vagrant-hostmanager/hosts_file.rb index 94d0933..c1dcf6e 100644 --- a/lib/vagrant-hostmanager/hosts_file.rb +++ b/lib/vagrant-hostmanager/hosts_file.rb @@ -10,7 +10,13 @@ module VagrantPlugins realhostfile = '/etc/inet/hosts' move_cmd = 'mv' elsif (machine.communicate.test("test -d $Env:SystemRoot")) - realhostfile = "#{ENV['WINDIR']}\\System32\\drivers\\etc\\hosts" + windir = nil + machine.communicate.execute("echo %SYSTEMROOT%", {:shell => :cmd}) do |type, contents| + if type == :stdout + windir = contents.gsub("\r\n", '') + end + end + realhostfile = "#{windir}\\System32\\drivers\\etc\\hosts" move_cmd = 'mv -force' else realhostfile = '/etc/hosts' From debf5e732a51976ba9f94075cdf1741a1b549cec Mon Sep 17 00:00:00 2001 From: Matthew Hopkins Date: Tue, 18 Mar 2014 09:00:11 -0400 Subject: [PATCH 2/2] winder update --- lib/vagrant-hostmanager/hosts_file.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/vagrant-hostmanager/hosts_file.rb b/lib/vagrant-hostmanager/hosts_file.rb index a08be74..7c4ac8f 100644 --- a/lib/vagrant-hostmanager/hosts_file.rb +++ b/lib/vagrant-hostmanager/hosts_file.rb @@ -10,11 +10,9 @@ module VagrantPlugins realhostfile = '/etc/inet/hosts' move_cmd = 'mv' elsif (machine.communicate.test("test -d $Env:SystemRoot")) - windir = nil + windir = "" machine.communicate.execute("echo %SYSTEMROOT%", {:shell => :cmd}) do |type, contents| - if type == :stdout - windir = contents.gsub("\r\n", '') - end + windir << contents.gsub("\r\n", '') if type == :stdout end realhostfile = "#{windir}\\System32\\drivers\\etc\\hosts" move_cmd = 'mv -force'