Symfony - can't clear cache through command

天大地大妈咪最大 提交于 2020-01-15 08:07:18

问题


I'm working on a vagrant machine (Homestead). In my Homestead.yml I have:

sites:
  - map: myproject.local
    to: /home/vagrant/projects/myproject/web
    type: symfony

I'm working with Symfony version 3.3 on PHP 7.1.2.

The problem is when I try to execute the command php bin/console cache:clear I'm getting the following error:

[Symfony\Component\Filesystem\Exception\IOException] Failed to remove directory "/home/vagrant/projects/vkfilestore-code/var/cache/de~/pools": .

In my AppKernel.php I have:

public function getCacheDir()
{
    return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
}

When I dump $this->getEnvironment() it says dev.

What could be the problem here?


回答1:


This is a Virtual platform related issue.A simple workaround is to remove manually.

$ sudo rm -rf app/cache/*

Read more about this issue app/console cache:clear problem




回答2:


Most prpbably it is a permission issue. Give permission like

sudo chmod -R 777 app/cache/

This should solve your problem. If the problem still persist do :-

sudo rm -rf app/cache/
php bin/console cache:clear --env=prod
sudo chmod -R 777 app/cache/


来源:https://stackoverflow.com/questions/47796710/symfony-cant-clear-cache-through-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!