Vagrant Chown Silently Fails
Vagrant Fails To Change File Permissions In Synced Folder
Setting up a LAMP Vagrant sandbox, I kept running on different issues that boiled down to this: I could change/set permissions for files and directories outside the vagrant synced folder, and for files inside the synced folder. But not directories.
As it turns out, there is a constraint from VirtualBox on vagrant disallowing you to set permissions on the synced folder from inside the guest OS.
This was the initial setup in the Vagrant file:
config.vm.synced_folder "./app", "/var/www"
If you check the documentation for synced folders, you can see that some of the different options look promising. To modify the owner/group
config.vm.synced_folder "./app", "/var/www", owner: "www-data", group: "www-data"
And then, using mount_options
assign the permissions for the synced from the vagrant file:
config.vm.synced_folder "./app", "/var/www", :owner=> 'www-data', :group=>'www-data',
:mount_options => ['dmode=775', 'fmode=775']