Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix permission denied while running vendor/bin/phpunit in a laravel project

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.

like image 491
Jin Aazoe Avatar asked Jul 22 '16 08:07

Jin Aazoe


4 Answers

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.

like image 122
Julio Garcés Teuber Avatar answered Nov 04 '22 02:11

Julio Garcés Teuber


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
like image 21
Babatunde Adeyemi Avatar answered Nov 04 '22 02:11

Babatunde Adeyemi


Deleting the vendor folder and doing composer install worked for me.

like image 44
Robertme Avatar answered Nov 04 '22 03:11

Robertme


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
like image 22
Maksim Ivanov Avatar answered Nov 04 '22 04:11

Maksim Ivanov