diff --git a/lib/vagrant-hostmanager/hosts_file/updater.rb b/lib/vagrant-hostmanager/hosts_file/updater.rb index 97d412c..8df2585 100644 --- a/lib/vagrant-hostmanager/hosts_file/updater.rb +++ b/lib/vagrant-hostmanager/hosts_file/updater.rb @@ -56,7 +56,12 @@ class << self copy_proc = Proc.new { windows_copy_file(file, hosts_location) } else hosts_location = '/etc/hosts' - copy_proc = Proc.new { `sudo cp #{file} #{hosts_location}` } + copy_proc = Proc.new { + tmp = Tempfile.new('hosts.local') + FileUtils.cp(file, tmp.path()) + `sudo cp #{tmp.path()} #{hosts_location}` + tmp.close! + } end FileUtils.cp(hosts_location, file)