Missing write permissions in directory pub/static when run bin/magento setup:upgrade
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.
I ran into this error in development because of a broken symbolic link.
I had created a file in a module's view/frontend/web
directory that in developer
mode was deployed to the pub/static
directory using a symbolic link that pointed to the module's directory where the original file is stored.
At some point in development I removed the file from my module, but the symbolic link still existed in pub/static
pointing to a file that no longer existed. I expect this would also be the case if I had renamed one of the files.
If a site is in production
mode and has had bin/magento setup:static-content:deploy
run, that actually copies the files to the pub/static
directory instead of creating symbolic links.
In order to find this broken symbolic link I ran a command from the shell
find -L . -type l
Removing the broken symbolic link resolved the problem (for example using find -L . -type l -exec rm {} \;
).
Inside your Magento root directory run the commands below and your issue should be gone:
$ rm -rf pub/static/*
$ php bin/magento setup:static-content:deploy
Worked for me.