The day before, I updated a new module and it was working normally. Now, when I run bin/magento setup:upgrade
, I receive the below Exception. I tried setting permissions to 777 (or 770) for the pub
folder in Magento 2 but it is not working.
[Exception]
Missing write permissions to the following directories: 'pub/static'
Best Answer
TL;DR truncate
pub/static
folder.For me, I had an older installation, which probably had some symlinks and old files which no longer exist.
The issue
checkInstallationFilePermissions
is that it checks the permissions recursively. Files and folders. I had a missing symlink, and that returned false on the check if it's writable.How to debug:
setup/src/Magento/Setup/Model/FilePermissions.php
Goto line 143 in method
checkRecursiveDirectories
Add the lines
var_dump($subDirectory);var_dump($subDirectory->isWritable());
Re run
bin/magento setup:upgrade
now you'll see what is really wrong, and you can fix it. Personally i remove everything in
pub/static
, this will be auto generated content so you should not be worried about that.