$ php -v):=> PHP 7.2.1-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Jan 5 2018 13:54:13) ( NTS )
$ php-cs-fixer -V):=> PHP CS Fixer 2.10.0 Bowling Bear
=> vendor/bin/php-cs-fixer fix
Hello, i encountered some issues with Vagrant NFS.
There is a problem with \PhpCsFixer\Cache\FileHandler::write() which uses file_put_contents (in line 86) with third parameter LOCK_EX - this causes error on NFS Vagrant mounts:
[Symfony\Component\Filesystem\Exception\IOException]
Failed to write file ".php_cs.cache", "no reason available".
The same problem was resolved here https://github.com/symfony/symfony/issues/25336 by simply remove LOCK_EX.
Thanks for reporting!
Related to this https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/1854 issue, which as not resolved as it was hard to reproduce.
Could you propose a fix, or if a PR was raised test it to see if it works on a setup that is currently broken?
IMHO the fix is simple - remove LOCK_EX :) Will it be a real problem to remove that lock? I think that CS fixing is not a job that needs (high) concurrency support.
My software setup:
Microsoft Windows [Version 10.0.16299.192]5.2.6 r120293 (Qt5.6.2)2.0.1NFS settings (in Vagrantfile):
config.vm.synced_folder ".", "/vagrant",
mount_options: ["actimeo=1"],
nfs: true,
linux__nfs_options: ["rw", "no_subtree_check", "all_squash", "async"]
On this setup bug can be reproduced. Symfony bug https://github.com/symfony/symfony/issues/25336 also affect me so i'm 100% sure that this is the LOCK_EX problem.
If you want full Vagrantfile look here: https://github.com/PabloKowalczyk/Todora/blob/master/Vagrantfile
Do you need more details or i missed something?
Labelled Easy Pick; to resolve this issue the LOCK_EX flag has to be removed when handling the cache file. The target branch should be the lowest we support.
Just in case someone lands here from Google (and can't update): I lost some considerable time trying to figure this out. I have tried several different configurations. Nothing worked, so I stepped down a level and tried to configure it directly between the guest instance and the host machine (i.e. manually editing /etc/exports and issuing mounts). It paid off :)
The final minimal configuration that worked for my setup (Ubuntu 17.10, Vagrant 2.0.2) is this:
config.vm.synced_folder ".", "/vagrant",
:nfs => true,
:nfs_version => 4,
:nfs_udp => false,
:mount_options => ['sec=sys']
keep in mind that PHP CS Fixer doesn't require a lock on newest 2.2 LTS and latest non-LTS versions ;)
Most helpful comment
Just in case someone lands here from Google (and can't update): I lost some considerable time trying to figure this out. I have tried several different configurations. Nothing worked, so I stepped down a level and tried to configure it directly between the guest instance and the host machine (i.e. manually editing
/etc/exportsand issuingmounts). It paid off :)The final minimal configuration that worked for my setup (Ubuntu 17.10, Vagrant 2.0.2) is this: