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

Permission denied - C:/Windows/system32/drivers/etc/hosts (Errno::EACCES) #89

Closed
YAmikep opened this issue Dec 18, 2015 · 22 comments
Closed
Assignees
Labels

Comments

@YAmikep
Copy link

YAmikep commented Dec 18, 2015

I get this error on the first vagrant up:
Permission denied - C:/Windows/system32/drivers/etc/hosts (Errno::EACCES)

Windows 10
Virtualbox 5.0.10
vagrant 1.7.4

C:/Users/Michael/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.1/lib/vagrant-hostsupdater/HostsUpdater.rb:85:in `initialize': Permission denied - C:/Windows/system32/drivers/etc/hosts (Errno::EACCES)
        from C:/Users/Michael/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.1/lib/vagrant-hostsupdater/HostsUpdater.rb:85:in `open'
        from C:/Users/Michael/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.1/lib/vagrant-hostsupdater/HostsUpdater.rb:85:in `addToHosts'
        from C:/Users/Michael/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.1/lib/vagrant-hostsupdater/HostsUpdater.rb:45:in `addHostEntries'
        from C:/Users/Michael/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.1/lib/vagrant-hostsupdater/Action/UpdateHosts.rb:17:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/set_hostname.rb:16:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/providers/virtualbox/action/forward_ports.rb:31:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/providers/virtualbox/action/network.rb:121:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/providers/virtualbox/action/clear_network_interfaces.rb:26:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/providers/virtualbox/action/prepare_nfs_settings.rb:18:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/synced_folders.rb:86:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/synced_folder_cleanup.rb:28:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/synced_folders/nfs/action_cleanup.rb:19:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/providers/virtualbox/action/prepare_nfs_valid_ids.rb:12:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:160:in `handle'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:42:in `block in call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/environment.rb:516:in `lock'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:41:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/providers/virtualbox/action/prepare_forwarded_port_collision_params.rb:30:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/env_set.rb:19:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/provision.rb:80:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/providers/virtualbox/action/clear_forwarded_ports.rb:15:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/providers/virtualbox/action/set_name.rb:50:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/providers/virtualbox/action/clean_machine_folder.rb:17:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/providers/virtualbox/action/check_accessible.rb:18:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builder.rb:116:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/call.rb:53:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builder.rb:116:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/call.rb:53:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builder.rb:116:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/call.rb:53:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/box_check_outdated.rb:68:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/providers/virtualbox/action/match_mac_address.rb:16:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/providers/virtualbox/action/import.rb:32:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/providers/virtualbox/action/customize.rb:40:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/providers/virtualbox/action/check_accessible.rb:18:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builder.rb:116:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/call.rb:53:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/handle_box.rb:56:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builder.rb:116:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/call.rb:53:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/Users/Michael/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.1/lib/vagrant-hostsupdater/Action/RemoveHosts.rb:23:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builder.rb:116:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/machine.rb:214:in `action_raw'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/machine.rb:191:in `block in action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/environment.rb:516:in `lock'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/machine.rb:178:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/machine.rb:178:in `action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'
@YAmikep
Copy link
Author

YAmikep commented Dec 18, 2015

Nevermind, I think I found why. I'm using git bash through conemu and I have to start gitbash as administrator.
Is that correct?
Thanks

@YAmikep
Copy link
Author

YAmikep commented Dec 18, 2015

One thing I have noticed though, by running as the administrator, the VM does not appear in VirtualBox anymore (because it's seen as a different user, explained by this: hashicorp/vagrant#4286)

Also, I noticed that running it as administrator brings other constraints.
Is there a way to not run it as administrator?

@YAmikep
Copy link
Author

YAmikep commented Dec 18, 2015

I found a workaround in another issue ticket.

Open %SystemRoot%\system32\drivers\etc in Windows Explorer, locate the hosts file, right-click it and set the usage rights to the current user (the one you run vagrant under) to allow file modification.
The plugin has no problems to work then, you don't need to run vagrant as administrator.

If that is required, maybe this could be added to the documentation.

@moe2566
Copy link

moe2566 commented Dec 21, 2015

Having the same issue.
Problem here is that it worked from regular cli without elevated permissions up until I tried setting up a .cmd file to start vagrant on pc startup (which failed).

Here's the .cmd contents:

@echo OFF
cd C:\Users\xxx\Homestead
vagrant up

@ikesau
Copy link

ikesau commented Jun 12, 2016

I'd just like to add that I experienced this issue and was able to narrow it down to Kaspersky Anti-Virus. Disabling the service completely and restarting restored correct functionality.

I'll update this post when I find out which specific service it was that was causing issues.

@ronezone
Copy link

ronezone commented Sep 22, 2016

I just ran into this issue today on an Windows 10 installation I've had running for a couple months without any issues. Perhaps my issue was caused by not properly using 'vagrant halt' before shutdown? I can't be sure. In any event I suspect something hosed the VirtualBox VM, and here is how I resolved the following error. The output that followed the below error is almost exactly the same as @YAmikep output.

.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.2/lib/vagrant-hos tsupdater/HostsUpdater.rb:98:in 'initialize': Permission denied @ rb_sysopen - C :/WINDOWS/system32/drivers/etc/hosts (Errno::EACCES)

Vagrant 1.8.4
Virtualbox 5.0.24r108355
vagrant-hostsupdater 1.0.2

  1. I opened the Oracle VM VirtualBox Manager to check the status (Session was "locked.") So I right-clicked and selected "Remove..." It said it was in use and could not delete (locked-duh!); so I performed vagrant halt just in case and then rebooted. I reopened the Oracle VM VirtualBox Manager; right-clicked and selected "Remove..." and removed all files.
  2. Then I deleted the VirtualBox VM subfolder that had the same name as the VM I just removed (C:\Users\MyUsernameFolder\VirtualBox VMs\vagrant-local).
  3. Then I ran vagrant up --provision and everything is back to normal.

@tyler36
Copy link

tyler36 commented Nov 30, 2016

Have the same issue after updating Vagrant to 1.9 this morning.
Was working fine on 1.8,7.

Tried @ronezone suggestion but didn't work for me.

Vagrant 1.9
Virtualbox 5.1,8
vagrant-hostsupdater 1.0.2
Win10

@brettmax
Copy link

brettmax commented Dec 3, 2016

I've just encountered this issue while trying to setup a new VM with vagrant. Deleting the file at /users//.vagrant.d/tmp/hosts.temp (something like that, not the default hosts but the temporary copy of your hosts) seems to be doing the trick.

@tyler36
Copy link

tyler36 commented Dec 5, 2016

Tried deleting temp files as suggested by @brettmaxwellmorgan ('c:\users%username%.vagrant.d\tmp') directory but no luck for me

@zavham
Copy link

zavham commented Aug 23, 2017

copy this to windows/system32/drivers/etc/hosts file and will work 100%
192.168.33.10 scotchbox # VAGRANT: edbe6862c897161f0d259bff7f9ec15d (default) / 5244e62f-a3b6-4c02-8e85-91779ff41e8a
192.168.33.10 wpdistillery.dev # VAGRANT: 145a9dbfb3d9480a6d62121b4713ac68 (default) / 4f69a679-a181-479a-8002-7850ce86433f

@cgsmith
Copy link
Collaborator

cgsmith commented Mar 30, 2018

Should be fixed with the UAC escalation. Let me know if there are issues.

@cgsmith cgsmith closed this as completed Mar 30, 2018
@saranyapurushothaman
Copy link

Ran cmder as administrator. Issue fixed.

@danielgiljara
Copy link

Hi. This issue happened to me many times in Windows 10, by some reason the plugin vagrant-hostupdater begins to not ask for the UAC (the window that asks you for permissions). I don't know surely what things changed recently. I tunned the Windows disabling some services, I've VirtualBox at 5.2, don't changed due to a bug with 6.0 setup. I installed some Windows updates too. How can I debug this to fix it? Following the behavior at runtime by setting some debug code lines at mentioned ruby files in the callstack debugging code? Someone familiarized with this can help? Is very nice for me to have the dialog that advices me that the hosts file is going to be changed instead of opening the Notepad as administrator etc. If the bug persists and I don't found the cause probably I will reinstall the OS. Probably as well, I could do a test in each change I do in my OS when it is fixed to reproduce it again.
`

C:/Users//.vagrant.d/gems/2.4.4/gems/vagrant-hostsupdater-1.1.1.160/lib/vagrant-hostsupdater/HostsUpdater.rb:98:in `open'

`

@bredmor
Copy link

bredmor commented May 5, 2019

+1 to above, it's no longer prompting UAC and is now just failing on write attempt.

@danielgiljara
Copy link

I restored my Windows using a restore point and it works again. Something changed in the OS caused this problem. If I have the issue again I will investigate more.

@bredmor
Copy link

bredmor commented May 6, 2019

Changing the share type of the vagrant shared folder to NFS solved it for me.

@danielgiljara
Copy link

I don't know if is the same issue but now, again, when I'm doing a vagrant reload or a vagrant halt I'm having the same error again. The only thing I see for the moment is that it fails at:

C:/Users//.vagrant.d/gems/2.4.4/gems/vagrant-hostsupdater-1.1.1.160/lib/vagrant-hostsupdater/HostsUpdater.rb

      hostsFile = File.open(@@hosts_path, "w")

This is theoretically that the app is quering the OS for opening that file with write permissions and the OS is saying that is not permitted. Not knowing what thing do. I suppose that I will reinstall Windows and do an image, and restore it every day, Maybe it is possible to debug more with that programs that do a registry of all services and settings, and says you what changed or what program did you install when it starts failing. I will revise also antivirus settings, firewall, windows services.

@ghost
Copy link

ghost commented Jul 9, 2019

I have same problem with the host file...

image

Please! Help..

Emergency.....

@cgsmith
Copy link
Collaborator

cgsmith commented Jul 9, 2019

@ashokbaruaakas You should open an issue with Laragon. You are in the wrong GitHub issue.

@bunda3d
Copy link

bunda3d commented Nov 20, 2019

I found a workaround in another issue ticket.

Open %SystemRoot%\system32\drivers\etc in Windows Explorer, locate the hosts file, right-click it and set the usage rights to the current user (the one you run vagrant under) to allow file modification.
The plugin has no problems to work then, you don't need to run vagrant as administrator.

If that is required, maybe this could be added to the documentation.

This worked for me too--went to the hosts file, right-clicked, "edit" button and chose the "Users" profile to add all permission checks to. Was warned by windows popup.
Reentered "vagrant up" (vagrant provision did not work) and it started installing ansible and other dependencies.

@codekandis
Copy link

codekandis commented Mar 13, 2020

I found a workaround in another issue ticket.

Open %SystemRoot%\system32\drivers\etc in Windows Explorer, locate the hosts file, right-click it and set the usage rights to the current user (the one you run vagrant under) to allow file modification.
The plugin has no problems to work then, you don't need to run vagrant as administrator.

If that is required, maybe this could be added to the documentation.

I highly discourage everyone from doing this. In fact: the result allows every application running under the current user to modify the hosts file without further questions or possibilities of intervention. This is an enormous security issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

14 participants