geerlingguy / packer-boxes

Jeff Geerling's Packer build configurations for Vagrant boxes.
https://app.vagrantup.com/geerlingguy
MIT License
651 stars 304 forks source link

Folder permission issues on Ubuntu 18.04 with PHP. #57

Closed BenjaminLeibinger closed 4 years ago

BenjaminLeibinger commented 4 years ago

I have to following setup:

Host: Ubuntu 18.04, Virtualbox 5.2.16

My Vagrantfile:

Vagrant.configure("2") do |config|
#  config.vm.box = "ubuntu/bionic64"
  config.vm.box = "geerlingguy/ubuntu1804"
    config.vm.provider "virtualbox" do |vb|
    vb.name = "ubuntu_php_permission"
    vb.memory = 4096
    vb.cpus = 2
    end
end

The test.php file:

<?php

$dir = $argv[1];

$defaultIterator = new \RecursiveDirectoryIterator($dir);
$defaultIterator->setFlags(\RecursiveDirectoryIterator::SKIP_DOTS);

foreach ($defaultIterator as $file){
    echo "file: " .$file->getFilename() . PHP_EOL;
}

Then i run the following commands

vagrant up
sudo apt update
sudo apt install php-cli

php /vagrant/test.php /vagrant

In my case i dont see any output. If i switch the vagrant box to "ubuntu/bionic64" i get the files in the folder listed.

Thats just a simple example.

I found this Problem in combination with Drupal 8 / Drush 9 which is mounted as a default virtualbox share in the vagrant box and Drush does not find any commands. I know nfs is the better solution for mounting drupal, but in this case nfs is not possible.

There are two interesting things:

  1. if i use php method scandir -> i can list the files.
  2. On Mac this problem does not occur.
geerlingguy commented 4 years ago

@BenjaminLeibinger - That sounds like it would more likely be an issue with Vagrant and/or VirtualBox, especially considering that scandir() works, and it works in both cases on Mac... I'm guessing something in the default share might be messing with this?

I can't think of anything in my box configuration that would cause any problems with the default shared folder method, so it's very strange that it doesn't occur with ubuntu/bionic64.

geerlingguy commented 4 years ago

Also that VirtualBox version is very old, I have been only building boxes for VirtualBox 6.0.x and 6.1.x for quite some time now. I would try updating to a newer VirtualBox version and see if the issue goes away.

BenjaminLeibinger commented 4 years ago

After Updating VirtualBox to 6.1 and Vagrant to 2.2.8 it works. Thanks!