19

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'

  • did u manage to resolve this problem ? if so pls post the solution. – Reena Parekh Dec 2 '15 at 12:40
  • Are you have same issue ? – Thao Pham Dec 2 '15 at 13:05
  • yes i am facing the same issue. how did u resolve it ? – Reena Parekh Dec 2 '15 at 13:26
  • I comment some line code in core. Are you want do as me? – Thao Pham Dec 2 '15 at 13:28
  • 1
    i posted my relsove in post below. I can try with it – Thao Pham Dec 2 '15 at 13:35

14 Answers 14

30

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:

  1. setup/src/Magento/Setup/Model/FilePermissions.php

  2. Goto line 143 in method checkRecursiveDirectories

  3. Add the lines var_dump($subDirectory);var_dump($subDirectory->isWritable());

  4. 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.

  • 1
    I removed pub/static completely, after I ran setup:upgrade the only folder inside pub/static is __requirejs folder. Css are missing, no styling what so ever.... Man.. do I wish i haven't done that – Lachezar Raychev Feb 17 '16 at 16:13
  • how can I restore everything in pub/static ? – Lachezar Raychev Feb 17 '16 at 16:34
  • 2
    everything was going so well.... :) i really start to despise this framework – Lachezar Raychev Feb 17 '16 at 17:11
  • 3
    If you remove the contents of pub/static just make sure you don't remove pub/static/.htaccess as it is part of the code base and doesn't get recreated: github.com/magento/magento2/tree/2.0/pub/static – mttjohnson Jun 8 '16 at 15:24
  • Perfecto! This was it.. – Arvind07 Jul 10 '16 at 10:45
11

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 {} \;).

  • This was the answer to my issue as well, thanks mttjohnson! – Joshua Soileau Jul 6 '16 at 14:15
4

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.

  • This will delete .htaccess file too. You need .htaccess file. – Adarsh Khatri Nov 4 at 7:50
2

You should setup the permissions as it is described in the official documentation: http://devdocs.magento.com/guides/v2.0/install-gde/install/file-system-perms.html

  • 1
    can you the actual permissions just cause in-case the url changes. – rob3000 Nov 23 '15 at 8:27
  • I try again but it not working – Thao Pham Nov 23 '15 at 8:31
  • Do not forget to do it recursively into subdirectories: pub, pub/static, etc. – Mage2.PRO Nov 23 '15 at 8:33
  • ownership is as important as permissions; check the above link and also devdocs.magento.com/guides/v2.0/install-gde/prereq/…. You must have two users; a local user and the web server user – Steve Johnson Nov 23 '15 at 15:34
  • the whole idea of setting the permissions at application level is wrong so I think people should avoid the documentation at that section. it will be updated in next versions according to their github issues – Claudiu Creanga Apr 4 '16 at 16:59
1

This is my resolved temporary. I comment line 744 and 466 in <magento_dir>/setup/src/Magento/Setup/Model/Installer.php.

This is line code:

$this->checkInstallationFilePermissions();

I need solution don't change core file.

  • The problem is likely due to a broken symlink (answered below) under the pub/static directory. Removing the broken symlink should resolve the problem without modifying core files. – mttjohnson Jan 7 '16 at 17:24
  • newtips.co/magento/questions/91184/… This will work – Envision Ecommerce Mar 1 '16 at 6:31
  • @EnvisionEcommerce the link doesn't work. – MagePsycho Jul 5 '18 at 7:04
1

Fix bin/magento permission denied

chmod u+x bin/magento

0

These folders needs to have the right permissions like described in: http://devdocs.magento.com/guides/v2.0/install-gde/install/file-system-perms.html

When you remove the contents of the pub/static folder and you give the pub/static folder the permission 770, the message will not show up again.

0

I had the same problem where i could not install Magento via the command line. Simply creating the folder pub/static solved the problem.

0

If someone is having this issue on Windows os. Just execute the command on a Administrator command prompt and it will work like a charm. Hope this helps someone.

0

In my case running upgrade command through non-root user or a user with limited permissions was causing the error. Make sure you run the upgrade command with a user with enough permissions.

0

I verified many times write permissions and everything was good.

  1. I commented this row, which throw me an exception.
  2. Then I ran setup:upgrade.
  3. Reverted back the row with exception
  4. Issue didn't reproduce no more
0

Run the following command, for the following three IP addresses:

<Magento-Directory>php bin\magento maintenance:allow-ips 127.0.0.1, 
<Magento-Directory>php bin\magento maintenance:allow-ips "the ip of my localhost given by the NAT-Router" and
<Magento-Directory>php bin\magento maintenance:allow-ips  "the ip of the NAT-Router" 
0

don't use this :

rm -r pub/static

it will remove all files even .htaccess

you can use this will be better :

rm -rf pub/static/frontend
rm -rf pub/static/adminhtml

after that use :

php bin/magento setup:static-content:deploy en_US -f 
-1

just remove pub/static folder from your magento2

rm -r pub/static

then deploy static content of magento2

php bin/magento setup:static-content:deploy

by using this process my same problem solved.

  • 4
    You shouldn't remove the entire pub/static directory as it contains a .htaccess file that is important, and the .htaccess file will not get recreated on any static content deploy. You could run rm -r pub/static/* and that should avoid removing the .htaccess file. – mttjohnson Jan 7 '16 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.