Recent Posts


Missing Write Permission During `bin/magento setup:upgrade`


Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

I’m seeing the following error a lot when running bin/magento setup:upgrade

Missing write permissions to the following directories: ’/Users/alanstorm/Sites/magento-2-with-keys/magento2/pu

Extra frustratingly – if I look at every file and directory in pub/static, they all have fully world readable, writable, and executable permissions. (this isn’t my favorite way to run mod_php, but Magento 2 seems to have left us non-FastCGI dinosaurs on our own)

The only way I’ve found to fix this is to delete my entire pub/static directory and let Magento regenerate it.

I finally got to the bottom of this today. It looks like Magento’s permissions checking code will resolve symlinks to their final folder when checking permissions.

If you’re working your way through my Magento 2 for PHP MVC Developers series, you’ll know that Magento creates symlinks to frontend asset files when you’re running in developer mode.

# ls -l
lrwxrwxrwx  1 _www  staff  135 Jan 20 20:00  /path/to/magento/pub/static/frontend/Magento/ultimo/en_US/Package_Model/file.js -> /path/to/magento/pub/static/frontend/Magento/ultimo/en_US/Package_Model/file.js

When Magento does a permissions check during a run of setup:upgrade, it checks the actual file instead of the symlink. This means if your symlink has the correct permissions for Magento to be able to remove/change it, but the file in the actual module does not, the permissions check fails.

Unfortunately, the only fix is still to remove these symlinks and let Magento regenerate them on the next request.

find pub/static -type l -exec rm '{}' ;    

I’ve opened an issue w/r/t this, but given the general mess of permissions for mod_php users in Magento 2 and the fact this issue probably spans engineering groups – I’m not hopeful we’ll see a fix.

Copyright © Alan Storm 1975 – 2019 All Rights Reserved

Originally Posted: 23rd January 2016