symfony: Cache:clear fails on 2.6

I just upgraded project to 2.6.1 from 2.5.8.

Running php bin/console cache:clear for a second time fails. Its reproducible with vanilla installation. Here is the screenshot:

26

I’m running these commands on Ubuntu 14.10, it also reproducible with (production servers) Debian Wheezy 7.6 with SYMFONY_ENV=prod.

https://twitter.com/oungur/status/541187828827578369

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 1
  • Comments: 28 (21 by maintainers)

Commits related to this issue

Most upvoted comments

Everyone who override the getCacheDir() in app/AppKernel.php like

    public function getCacheDir()
    {
        return $this->rootDir.'/../var/cache/'.$this->environment;
    }

may avoid this issue by using realpath()

    public function getCacheDir()
    {
        return realpath($this->rootDir.'/../var/cache).'/'.$this->environment;
    }

or have a look at PR #12928, which does basically the same, but for all paths in the generated container.

I don’t know if the getCacheDir is overridden by default, for setups were the Symfony 3.0 structure was chosen when installing via composer. If not, you can try to override it nonetheless.

Looks like it happens when using a custom cache location. Maybe something to do with #12784?

Steps to reproduce:

  1. Install a new app: symfony new myapp

  2. cd myapp

  3. Add to app/AppKernel.php:

    public function getCacheDir()
    {
        return $this->rootDir.'/../var/cache/'.$this->environment;
    }
    
    public function getLogDir()
    {
        return $this->rootDir.'/../var/logs';
    }
    
  4. app/console ca:cl (works)

  5. app/console ca:cl (error)

[RuntimeException]                                                            
  Unable to write in the ".../myapp/app/../var/cache/de_" directory