Skip to content

cache:clear not working in PROD after renaming a variable in .env #59279

Closed
@ThomasLandauer

Description

@ThomasLandauer

Symfony version(s) affected

7.2.1

Description

In Symfony 7.1, I had a variable named MAILER_DSN in my .env.
I now renamed it to FOO_MAILER_DSN and upgraded to Symfony 7.2. This worked fine on my DEV machine.
When deploying to PROD, I did (as recommended at https://symfony.com/doc/current/deployment.html#d-clear-your-symfony-cache)

APP_ENV=prod APP_DEBUG=0 php bin/console cache:clear

And got:

In EnvVarProcessor.php line 221:
Environment variable not found: "MAILER_DSN".

So I deleted the cache folder manually:

rm -rf var/cache/prod/*

And then everything was fine:

APP_ENV=prod APP_DEBUG=0 php bin/console cache:clear

Gave me the expected:

// Clearing the cache for the prod environment with debug false
[OK] Cache for the "prod" environment (debug=false) was successfully cleared.

How to reproduce

See above

Possible Solution

I already suggested to mention the manual way (rm ...) on the deployment page: symfony/symfony-docs#19836

So this is now the second issue with cache:clear I'm running into while deploying.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions