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– Reena Parekh2015年12月02日 12:40:01 +00:00Commented Dec 2, 2015 at 12:40
-
Are you have same issue ?LinoPham– LinoPham2015年12月02日 13:05:29 +00:00Commented Dec 2, 2015 at 13:05
-
yes i am facing the same issue. how did u resolve it ?Reena Parekh– Reena Parekh2015年12月02日 13:26:09 +00:00Commented Dec 2, 2015 at 13:26
-
I comment some line code in core. Are you want do as me?LinoPham– LinoPham2015年12月02日 13:28:22 +00:00Commented Dec 2, 2015 at 13:28
-
1i posted my relsove in post below. I can try with itLinoPham– LinoPham2015年12月02日 13:35:26 +00:00Commented Dec 2, 2015 at 13:35
15 Answers 15
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.phpGoto line 143 in method
checkRecursiveDirectoriesAdd 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.
-
1I 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 thatLachezar Raychev– Lachezar Raychev2016年02月17日 16:13:14 +00:00Commented Feb 17, 2016 at 16:13
-
how can I restore everything in pub/static ?Lachezar Raychev– Lachezar Raychev2016年02月17日 16:34:31 +00:00Commented Feb 17, 2016 at 16:34
-
2everything was going so well.... :) i really start to despise this frameworkLachezar Raychev– Lachezar Raychev2016年02月17日 17:11:15 +00:00Commented Feb 17, 2016 at 17:11
-
3If 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/staticmttjohnson– mttjohnson2016年06月08日 15:24:15 +00:00Commented Jun 8, 2016 at 15:24
-
Perfecto! This was it..Arvind07– Arvind072016年07月10日 10:45:25 +00:00Commented Jul 10, 2016 at 10:45
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– Joshua Soileau2016年07月06日 14:15:26 +00:00Commented Jul 6, 2016 at 14:15
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
.htaccessfile too. You need.htaccessfile.Adarsh Khatri– Adarsh Khatri2019年11月04日 07:50:06 +00:00Commented Nov 4, 2019 at 7:50 -
1@AdarshKhatri no it won't.
rm -rf pub/static/*doesn't delete dotfiles. Go ahead and try with a test directory.rm -rf pub/static/.* (notice the dot)would delete htaccess.Erik B– Erik B2020年07月22日 22:45:01 +00:00Commented Jul 22, 2020 at 22:45 -
@medina Thank you 🙏🏻Said Erraoudy– Said Erraoudy2021年05月15日 11:29:48 +00:00Commented May 15, 2021 at 11:29
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
-
1can you the actual permissions just cause in-case the url changes.rob3000– rob30002015年11月23日 08:27:37 +00:00Commented Nov 23, 2015 at 8:27
-
I try again but it not workingLinoPham– LinoPham2015年11月23日 08:31:26 +00:00Commented Nov 23, 2015 at 8:31
-
Do not forget to do it recursively into subdirectories: pub, pub/static, etc.Dmitrii Fediuk– Dmitrii Fediuk2015年11月23日 08:33:20 +00:00Commented Nov 23, 2015 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 userSteve Johnson– Steve Johnson2015年11月23日 15:34:07 +00:00Commented Nov 23, 2015 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 issuesClaudiu Creanga– Claudiu Creanga2016年04月04日 16:59:22 +00:00Commented Apr 4, 2016 at 16:59
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– mttjohnson2016年01月07日 17:24:15 +00:00Commented Jan 7, 2016 at 17:24
-
newtips.co/magento/questions/91184/… This will workEnvision eCommerce– Envision eCommerce2016年03月01日 06:31:37 +00:00Commented Mar 1, 2016 at 6:31
-
@EnvisionEcommerce the link doesn't work.MagePsycho– MagePsycho2018年07月05日 07:04:23 +00:00Commented Jul 5, 2018 at 7:04
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.
Fix bin/magento permission denied
chmod u+x bin/magento
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.
I had the same problem where i could not install Magento via the command line.
Simply creating the folder pub/static solved the problem.
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.
I verified many times write permissions and everything was good.
- I commented this row, which throw me an exception.
- Then I ran setup:upgrade.
- Reverted back the row with exception
- Issue didn't reproduce no more
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"
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
You must have deleted pub/static (except .htacess) under the impression that it will be created upon next execution but after executing upgrade command you ended with this :)
Don't worry, execute the deploy command using -f to have everything in flow and expected.
I had the same issue but managed my old working source by following the above trick.
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.
-
5You 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– mttjohnson2016年01月07日 17:20:11 +00:00Commented Jan 7, 2016 at 17:20
Explore related questions
See similar questions with these tags.