Whenever I execute vendor/bin/phpunit
in root path of my laravel project, it gives back a Permission denied error. How can I fix this problem?
Important: I don't want to use composer update
or delete some or all the vendor/
dir then use composer install
as these methods will change too much files, which my master will not agree.
ps: lrwxrwxrwx 1 work work 26 Jul 21 07:10 phpunit -> ../phpunit/phpunit/phpunit
-rwxrwxrwx 1 work work 1199 Jul 22 08:19 ./vendor/phpunit/phpunit/phpunit
and chmod 775 -R vendor
doesn't work.
What you should do is call with php:
$ php ./vendor/bin/phpunit
PHPUnit 4.8.35 by Sebastian Bergmann and contributors.
I get the same error tying to execute it without php interpreter:
$ ./vendor/bin/phpunit
bash: ./vendor/bin/phpunit: Permission denied
Hope this helps you.
You can solve this by updating the Vagrantfile of your setup, particularly the fmode
of your web root synced_folder
folder.
Change:
config.vm.synced_folder ".", "/vagrant", :mount_options => ["dmode=777", "fmode=666"]
to :
config.vm.synced_folder ".", "/vagrant", :mount_options => ["dmode=777", "fmode=777"]
For scotch-box,
Change:
config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=666"]
to :
config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=777"]
After doing this, reload your configuration:
$ vagrant reload
Deleting the vendor
folder and doing composer install
worked for me.
What you see in the vendor/bin
directory is symlinks. Symlinks might have the right permissions, but the files they are pointing to might not. Ensure that both symlinks and the files they are pointing to have the execute (x
) bit on.
# symlink
sudo chmod 0775 vendor/bin/phpunit
# the actual executable
sudo chmod 0775 vendor/phpunit/phpunit/phpunit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With