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 - /etc/hosts (Errno::EACCES) #92

Closed
dblencowe opened this issue Dec 23, 2015 · 45 comments
Closed

Permission denied - /etc/hosts (Errno::EACCES) #92

dblencowe opened this issue Dec 23, 2015 · 45 comments
Assignees

Comments

@dblencowe
Copy link

In the last week vagrant-hostmanager has stopped working on my machine. Rather than asking for my password to edit the hosts file it fails on an access denied with the message below.

I recently updated the plugin but I've been doing a load of other vagrant stuff recently so I'm not sure exactly what might have caused this. I'm running the latest OS X, Vagrant 1.7.4 and have got the same error on both Virtualbox and VMware Fusion.

==> default: Running cleanup tasks for 'ansible' provisioner...
/Users/dblencowe/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.1/lib/vagrant-hostsupdater/HostsUpdater.rb:85:in `initialize': Permission denied - /etc/hosts (Errno::EACCES)
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.1/lib/vagrant-hostsupdater/HostsUpdater.rb:85:in `open'
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.1/lib/vagrant-hostsupdater/HostsUpdater.rb:85:in `addToHosts'
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.1/lib/vagrant-hostsupdater/HostsUpdater.rb:45:in `addHostEntries'
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.1/lib/vagrant-hostsupdater/Action/UpdateHosts.rb:17:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/set_hostname.rb:16:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.5/lib/vagrant-vmware-fusion/action_farm.rb:726:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.5/lib/vagrant-vmware-fusion/action_farm.rb:953:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/synced_folders.rb:86:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-bindfs-0.4.6/lib/vagrant-bindfs/bind.rb:14:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/synced_folder_cleanup.rb:28:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/synced_folders/nfs/action_cleanup.rb:25:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.5/lib/vagrant-vmware-fusion/action_farm.rb:1025:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-hostmanager-1.6.1/lib/vagrant-hostmanager/action/update_all.rb:24:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/provision.rb:80:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-bindfs-0.4.6/lib/vagrant-bindfs/bind.rb:14:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builder.rb:116:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `block in run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/util/busy.rb:19:in `busy'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/call.rb:53:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.5/lib/vagrant-vmware-fusion/action_farm.rb:71:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.5/lib/vagrant-vmware-fusion/action_farm.rb:1055:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builder.rb:116:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `block in run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/util/busy.rb:19:in `busy'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/call.rb:53:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/box_check_outdated.rb:68:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.5/lib/vagrant-vmware-fusion/action_farm.rb:1347:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.5/lib/vagrant-vmware-fusion/action_farm.rb:273:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.5/lib/vagrant-vmware-fusion/action_farm.rb:143:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.5/lib/vagrant-vmware-fusion/action_farm.rb:1134:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.5/lib/vagrant-vmware-fusion/action_farm.rb:502:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/handle_box.rb:56:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builder.rb:116:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `block in run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/util/busy.rb:19:in `busy'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/call.rb:53:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.5/lib/vagrant-vmware-fusion/action_farm.rb:1347:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.5/lib/vagrant-vmware-fusion/action_farm.rb:99:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.5/lib/vagrant-vmware-fusion/action_farm.rb:273:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.5/lib/vagrant-vmware-fusion/action_farm.rb:160:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/dblencowe/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.1/lib/vagrant-hostsupdater/Action/RemoveHosts.rb:23:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builder.rb:116:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `block in run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/util/busy.rb:19:in `busy'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/machine.rb:214:in `action_raw'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/machine.rb:191:in `block in action'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/environment.rb:516:in `lock'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/machine.rb:178:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/machine.rb:178:in `action'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'
@dblencowe
Copy link
Author

So I've tried allowing my user (the one running the vagrant up) write access to /etc/hosts and am still getting the same error.

@timrosede
Copy link

i have the same issue :-(

@dblencowe
Copy link
Author

We ended up switching to vagrant-hostmanager. https://github.com/roots/trellis/pull/443/files

@timrosede
Copy link

thank you, i am switching too ;-)

@iandunn
Copy link

iandunn commented Jan 6, 2016

I started getting this problem today too, with:

  • OS X 10.11.2
  • Vagrant 1.7.4
  • vagrant-hostsupdater 1.0.1

Before today, it'd been working fine for more than a year. I updated to Vagrant 1.8.1, removed and re-installed all the plugins, and I'm still getting the error.

@bkeetman
Copy link

bkeetman commented Jan 7, 2016

@iandunn Same thing for me, I downgraded to 1.7.4 from 1.8.1 seeing a colleague with no issues was still running that version. Dit not have any effect...

@chrisgoddard
Copy link

Started having this problem today.

Tried updating to latest version of Vagrant and all plugins, but no dice.

For now I've had to uninstall hostsupdater and edit the hosts file manually but I'd love to know if anyone gets a solution for this.

@CameronCarranza
Copy link

Also happening here within the past few days, can't pinpoint what caused it. I recently upgraded to 1.8.1, so I tried reinstalling the plugins and even downgrading back to 1.7.4 to no avail.

@cgsmith
Copy link
Collaborator

cgsmith commented Jan 15, 2016

I am trying to replicate the issue but am not having any luck. Everything is working for me with my VagrantFiles.

OS X: 10.11.2
Vagrant: 1.8.1 & 1.7.4
vagrant-hostsupdater: 1.0.1

Can anyone share a vagrantfile that is not working?

@CameronCarranza
Copy link

Issue is occurring for me on VVV on a slightly older version.

@cgsmith
Copy link
Collaborator

cgsmith commented Jan 15, 2016

@Radau which is the slightly older version for you?

@CameronCarranza
Copy link

@cgsmith It was off of the develop branch roughly a year ago, so the Stable 1.2.0 release should be very similar to what I'm running.

@cgsmith
Copy link
Collaborator

cgsmith commented Jan 15, 2016

Ok - I will try 1.2.0 and report back. Thanks @Radau

@cgsmith
Copy link
Collaborator

cgsmith commented Jan 15, 2016

I cannot reproduce the issue with VVV 1.2.0.

    default: Guest Additions Version: 4.3.10
    default: VirtualBox Version: 5.0
==> default: [vagrant-hostsupdater] Checking for host entries
==> default: [vagrant-hostsupdater] Writing the following entries to (/etc/hosts)
==> default: [vagrant-hostsupdater]   192.168.50.4  vvv  # VAGRANT: 83037946dfa37530f4674910d5e3f329 (default) / ce2ceda4-91b1-4e71-bbfa-7fe2d64f1489
==> default: [vagrant-hostsupdater]   192.168.50.4  vvv.dev  # VAGRANT: 83037946dfa37530f4674910d5e3f329 (default) / ce2ceda4-91b1-4e71-bbfa-7fe2d64f1489
==> default: [vagrant-hostsupdater]   192.168.50.4  local.wordpress.dev  # VAGRANT: 83037946dfa37530f4674910d5e3f329 (default) / ce2ceda4-91b1-4e71-bbfa-7fe2d64f1489
==> default: [vagrant-hostsupdater]   192.168.50.4  local.wordpress-trunk.dev  # VAGRANT: 83037946dfa37530f4674910d5e3f329 (default) / ce2ceda4-91b1-4e71-bbfa-7fe2d64f1489
==> default: [vagrant-hostsupdater]   192.168.50.4  src.wordpress-develop.dev  # VAGRANT: 83037946dfa37530f4674910d5e3f329 (default) / ce2ceda4-91b1-4e71-bbfa-7fe2d64f1489
==> default: [vagrant-hostsupdater]   192.168.50.4  build.wordpress-develop.dev  # VAGRANT: 83037946dfa37530f4674910d5e3f329 (default) / ce2ceda4-91b1-4e71-bbfa-7fe2d64f1489
==> default: [vagrant-hostsupdater] This operation requires administrative access. You may skip it by manually adding equivalent entries to the hosts file.
Password:
==> default: Setting hostname...

Sets the host fine. Anyone willing to do a Google Hangout to track down this issue?

@cgsmith
Copy link
Collaborator

cgsmith commented Jan 15, 2016

Sorry you had to switch @dblencowe - I wish I could reproduce this issue for you so you wouldn't need to switch. It seems like the Ansible provisioner failed and was trying to perform cleanup tasks and at some point called the hook for cleaning up the host file.

@CameronCarranza
Copy link

I have tried running vagrant up on the stable release as well and it is happening to me. I have a feeling the issue either lies within OS X or Vagrant itself. There's no reason the sudo method should be failing, it doesn't even prompt it (for me at least), it just fails with Errno::EACCES as above.

I'm not sure if this is related but I did run into an issue with my system today where it was no longer prompting me for the password when sudoing (for ANY application) until I added Defaults tty_tickets into /etc/sudoers. Also I'm noticing an ACL is set on /etc/hosts. I removed this ACL earlier today and it appears to have come back with a reboot. Not sure if this is OS X or another application setting this, may be helpful though (my current user is cameron):

-rw-r--r--+ 1 root  wheel  1824 Jan 14 16:00 /etc/hosts
 0: user:cameron allow write

EDIT:
Here's my output as well, I don't believe it's any different though.

@CameronCarranza
Copy link

Just tried running Vagrant as the root user on my system and it looks like hostsupdater went through.

@CameronCarranza
Copy link

So I have a pretty awful solution for this. For whatever reason the OS X ACLs for my user don't seem to be applying applying to ruby (the one that allows my user to read/write without escalating privs ls -la /etc/hosts -rw-r-r-+ 1) and the ruby module appears to not be prompting for privilege escalation regardless.

I ran sudo chmod 666 /etc/hosts and all of the hosts add properly. Obviously this is something you should never really do, but it does work as a temporary fix for me at least. My permissions end up looking like so after running chmod ls -la /etc/hosts -rw-rw-rw-+ 1.

@jb510
Copy link

jb510 commented Jan 28, 2016

FWIW, this is also happening with vagrant-ghost (on VVV and HGV).

My guess is it's either related to the deprecated sudo warning I've been seeing... or a change to OS X permissions/security around /etc/hosts.

For now I've uninstalled both vagrant-hostsupdater and vagrant-ghost and am back to updating my hosts file manually.

@cgsmith
Copy link
Collaborator

cgsmith commented Jan 28, 2016

@jb510 do you know a way to duplicate this issue? I'm not sure that there is much I can do to help, the problem is not happening for me.

@Radau out of curiosity does a sudo vagrant up allow changes? That would point to the ACL like you were saying then.

@iandunn
Copy link

iandunn commented Jan 28, 2016

@jb510 I was seeing a sudoers warning around the same time this started, so that may be related. I had added an includedir statement to /private/etc/sudoers, and was getting an error like /Users/ian/dotfiles/sudoers.d is owned by uid 501, should be 0. The problem with vagrant-hostsupdater is still happening even after removing that includedir line and making the sudoers error message go away, though.

As far as OS X updates, 10.11.2 was released on December 11th, with a lot of potentially related security updates, but nothing that jumps out as the obvious cause. That was also almost 2 weeks before this issue was opened, which makes it seem like an unlikely cause, since somebody probably would have reported this issue closer to the time of the release.

@jb510
Copy link

jb510 commented Jan 28, 2016

@cgsmith It happens consistently for me. I'm not sure what the specific cause is. It does seem to have coincided with updating to OS X 10.11.3 or 10.11.4 Beta. But that could be purely coincidental.

Uninstalling hostsupdater and manually managing hosts vagrant comes up fine.

Setting hosts to 777 also works fine, so it does seem to be access related. Why the vagrant machine suddenly can no longer modify it I'm not sure.

@CameronCarranza
Copy link

@cgsmith I did not run sudo vagrant up, but I did run it as root earlier. Simply sudo su'd, copied my project in to an separate folder (just incase, didn't want to mess any of my data up), and ran vagrant up as the root user. Everything went through fine when I tried this.

@vaurdan
Copy link

vaurdan commented Jan 30, 2016

I'm having the exact same problem. Before it would ask for my sudo password, now it simply stops running with that same error.

@peterdewinter
Copy link

This should help:

sudo chmod +a "$USER allow write,append" /etc/hosts

@iandunn
Copy link

iandunn commented Feb 11, 2016

sudo chmod +a "$USER allow write,append" /etc/hosts

That might be acceptable as a temporary workaround, depending on your circumstances, but it's not a great permanent solution, because it would make you much more vulnerable to local DNS hijacking, since malware wouldn't need you trick you into entering your password.

@peterdewinter
Copy link

Correct, until a fix is available ... .

@jjeaton
Copy link

jjeaton commented Jul 14, 2016

This is still failing for me:

Vagrant 1.8.4
Virtualbox 5.0.24r108355
vagrant-hostsupdater 1.0.2

I get the same vagrant-hostsupdater/HostsUpdater.rb:85:in `initialize': Permission denied - /etc/hosts. Even if it could fail and be caught rather than killing the vagrant up, that would be a huge help.

@CameronCarranza
Copy link

CameronCarranza commented Jul 14, 2016

Yep, I don't believe a fix has been made available yet for the actual package. At this point I basically just resort to chmod'ing /etc/hosts every once in a while (issue reappears maybe once a month). Still a bad solution but if you have work that needs to be done it's been working for me

Edit: Mijathis solution is better in terms of permissions as well, so you may want to use that if it works.

@cgsmith
Copy link
Collaborator

cgsmith commented Jul 14, 2016

I'll be able to look into if the failure can be caught and just throw a warning but won't have time until later next week. PRs are welcomed!

I'll also try duplicating this next week on my box. Thanks for the info and suggestion @jjeaton

@jjeaton
Copy link

jjeaton commented Jul 14, 2016

Thanks @cgsmith!

FWIW, I am having the issue with latest VVV, latest Homestead and latest vip-quickstart.

@bickerstoff
Copy link

FWIW I'm having the same issue on OSX, Homestead, Vagrant 1.8.5, and Virtualbox 5.1.0. I was able to get around it by executing:
sudo chmod +a "user allow list,add_file,search,delete,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit" /etc/hosts

Where user is my username locally.

@ronezone
Copy link

ronezone commented Sep 21, 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 @dblencowe 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.

@degrovejazz
Copy link

Ran into the same problem (OSX host). Ran vagrant up with sudo and worked. Also had to add sudo with vagrant ssh.

@mabho
Copy link

mabho commented Feb 3, 2017

I am experiencing the same problem on my Windows machine. As with others in this thread, it used to work fine, but problems suddenly arose, probably due to a version update, I am not sure. My current Vagrant version is 1.8.6. I could overcome this issue by running my command line app as as Administrator (in my case, GIT Bash).

@craiglondon
Copy link

@mabho Check to see if the hosts.local file is read-only, once I removed the read-only attribute from that file, I was able to get past this error.

@surrealchemist
Copy link

surrealchemist commented May 18, 2017

I was discussing this with a co-worker, and running this on OS X and he was wondering if it could just be designed to prompt for a password somehow. If that is even possible, it might be preferred to modifying permissions on the hosts file.

Actually it seems like on my co-workers instance they get prompted for password but for some reason on mine it doesn't. Strange.

@johnkeates
Copy link

This happens when you set an ACL on /etc/hosts. Some apps (like Gas Mask) do this.

Check with ls -le /etc/hosts and delete the ACL with sudo chmod -R -N /etc/hosts

By default it has no ACL and is root:wheel owned with permissions rw/r/r

@metaColin
Copy link

I did not experience this issue prior to installing Gas Mask. @johnkeates good catch.

@johnkeates
Copy link

There are other apps and plugins that seem to mess with file ACL's, so even for those that didn't use Gas Mask, check your ACL's as they override permissions. :)

@surrealchemist
Copy link

Had this ACL on mine:
0: user:jkleiner allow write
Removing it, then loaded up Gas Mask. Once I edited a file I got prompted for password and the ACL was back. So that explains that. Would like to have them play nice together but not sure of the right way to go.

@johnkeates
Copy link

I suppose the only way is to not use Gas Mask until it is fixed. It doesn't seem to be explicitly set by Gas Mask itself (searching for ACL in the sources didn't yield any results), but it's possible that some sort of specific 'save this file as an admin' call to a Cocoa method sets the ACL automatically.

@Leland
Copy link

Leland commented Jul 21, 2017

Ugh, yeah - Gas Mask as well. Be sure to drop a thumbs-up if you've had the same problem on @johnkeates issue over yonder: 2ndalpha/gasmask#129

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

this bastard issue got me too — after installing gasmask earlier today for the first time. Thanks, all, for pioneering the way of pain, and its resolution :)

@iljamm
Copy link

iljamm commented Feb 20, 2019

In my case the culprit was Helm (hosts file manager just like Gas Mask), removing ACL (#92 (comment)) from the hosts file did it for me.

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

No branches or pull requests