Visitar URL original
.env file always overiding environment variables when used in params · Issue #6923 · Codeception/Codeception · GitHub
Skip to content

.env file always overiding environment variables when used in params #6923

Description

@GameBurrow

I've stumbled upon a bug reported here:
#6473

If configure my codeception.yml like this

params:
    - .env # load params from .env file
    - env # load params from environment vars

and a value comes both from .env file and ENV variable then the .env value is always used (no matter in which order you load the params).

In the original ticket the issue was fixed in #6477 however only SymfonyDotenv section was changed, could it be that the bug is still in if using PhpDotenv?

if (
class_exists(PhpDotenv::class) &&
class_exists(RepositoryBuilder::class) &&
method_exists(RepositoryBuilder::class, 'createWithDefaultAdapters')
) {
$repository = RepositoryBuilder::createWithDefaultAdapters()->make();
$dotenv = PhpDotenv::create($repository, codecept_root_dir(), codecept_relative_path($file));
return $dotenv->load();
}

Using verions 5.2.2 at the moment:

> php vendor/bin/codecept --version
Codeception 5.2.2

Activity

  1. changed the title [-].env file overiding environment variables[/-] [+].env file always overiding environment variables when used in params[/+] on Jan 21, 2026
  2. W0rma commented on Feb 17, 2026

    @W0rma
    Contributor

    could it be that the bug is still in if using PhpDotenv?

    I'm not using vlucas/phpdotenv but according to https://github.com/vlucas/phpdotenv?tab=readme-ov-file#immutability-and-repository-customization existing values are overwritten by default.
    Therefore, I guess the bug still exists for PhpDotenv.

    @GameBurrow Do you want submit a PR to fix the behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions