Search code examples
symfonysymfony6symfony-cache

Symfony cache:clear problem: No session available


The problem is very simple. The applications works as expected, no problems, sessions work, etc. But when I try to clear the cache:

bin/console c:c
// Clearing the cache for the dev environment with debug true                                                          

In RequestStack.php line 105:
                                            
  There is currently no session available.  

Any ideas?

Symfony version 6, all the latest packages.


Solution

  • The issue was in one of the Services, trying to call

    requestStack->getSession() 
    

    in the __construct method.

    The key to finding this error was to get a stack trace, using the bin/console c:c -vvv