Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug:dotenv command doesn't show environment variables #54640

Closed
CViniciusSDias opened this issue Apr 17, 2024 · 5 comments
Closed

debug:dotenv command doesn't show environment variables #54640

CViniciusSDias opened this issue Apr 17, 2024 · 5 comments

Comments

@CViniciusSDias
Copy link

Symfony version(s) affected

7.0.6

Description

If you have an environment variable set, the debug:dotenv command doesn't display it. It doesn't even display the values set in the .env files.

How to reproduce

On any symfony application, define a value in .env file. Let's use TEST as example:

TEST=value

Run php bin/console debug:dotenv and see that it's correctly displayed.

Now run TEST=other php bin/console debug:dotenv and see that it's not there anymore.

Possible Solution

No response

Additional Context

The command only shows what's in 'SYMFONY_DOTENV_VARS'. Since the value is now an env var, on Dotenv.php:192 it will skip the iteration and it will never be defined in $loadedVars nor in $_SERVER['SYMFONY_DOTENV_VARS'].

@javaDeveloperKid
Copy link
Contributor

Please create a reproducer.

@CViniciusSDias
Copy link
Author

Please create a reproducer.

As it's stated in the "steps to reproduce", it happens in any Symfony application and there is no code needed.
So I don't see much value in creating a repo with an empty Symfony project. 😅

@javaDeveloperKid
Copy link
Contributor

😅

Please keep this kind of emojis for yourself. It's not a place to emphasize your personal feelings about other people comments. Let's focus on the problem.

Indeed the env var declared in .env file is missing from debug:dotenv when the same env var passed when executing script

image

However I'm not sure this is wrong. With debug:dotenv command you list env vars in use that were declared in .env files. TEST was declared in .env but was not used as the real env var is used.

--help is ambiguous about what a user should expect.
Description says: List all dotenv files with variables and values what can be interpreted as list all variables (with corresponding values) declared in all dotenv files.
However Help says The bin/console debug:dotenv command displays all the environment variables configured by dotenv what can be interpreted as it displays only variables configured by dotenv - TEST is not configured by dotenv because it already exists.

Let's wait what other contributors or Core Team members will say.

@xabbuh xabbuh added the Dotenv label Apr 17, 2024
@nicolas-grekas
Copy link
Member

I think this behavior is WTF.
It'd be nice to be able to list all dotenv vars, even overridden ones. Ideally we would show both the overridden and dotenv values.

@HMRDevil
Copy link
Contributor

HMRDevil commented Apr 20, 2024

I'm sorry for my English.
A small comment. This behavior is also present in the 5.4 branch.
@nicolas-grekas Do you think it would look better this way?

image

nicolas-grekas added a commit that referenced this issue Apr 29, 2024
…v (HMRDevil)

This PR was merged into the 5.4 branch.

Discussion
----------

[Dotenv] show overridden vars too when running debug:dotenv

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #54640
| License       | MIT

See #54640

Commits
-------

ca2040e show overridden vars too
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants