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

Drush internal commands do not inherit $_ENV #674

Open
dotsam opened this issue Jun 6, 2024 · 1 comment
Open

Drush internal commands do not inherit $_ENV #674

dotsam opened this issue Jun 6, 2024 · 1 comment
Labels
drush State: Needs triage An issue or PR has not been assessed and requires a triage

Comments

@dotsam
Copy link

dotsam commented Jun 6, 2024

Some Drush commands will call exec() to run another Drush command (updatedb seems to be the main one, but there may be others). Somewhere in here either the load.environment.php from the Composer autoloader is not called, or $_ENV is clobbered in some way.

This was discussed in drush-ops/drush#4407 and the solution that worked for others, and works for me, is using $_SERVER in the settings.php file rather than $_ENV. The php.ini directive variables_order is referenced, and indeed, the comments for the directive indicate that in the php.ini-production file that most distros are based off of, Environment variables are not set by default.

The part I'm not clear on is that php-dotenv is manually populating the $_ENV global when it is called (via the autoloaded file), when a new drush process is exec()'d, it's not calling the Composer autoloader? But ENV vars from the parent process are copied into $_SERVER?

Ultimately, this issue is to see what should be done about $_ENV in .env.example, to see if it should be replaced with $_SERVER, getenv(), or just a note about the variables_order directive added.

@AlexSkrypnyk
Copy link
Collaborator

@dotsam
I can confirm that phpdotenv in it's current implementation within this project does not work in some cases. We are discussing it in this issue #379

@AlexSkrypnyk AlexSkrypnyk added drush State: Needs triage An issue or PR has not been assessed and requires a triage labels Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
drush State: Needs triage An issue or PR has not been assessed and requires a triage
Projects
None yet
Development

No branches or pull requests

2 participants