roots / bedrock

WordPress boilerplate with Composer, easier configuration, and an improved folder structure
https://roots.io/bedrock/
MIT License
6.15k stars 1.16k forks source link

phpdotenv warning about missing .env in theme folder #722

Closed tedw closed 4 weeks ago

tedw commented 4 months ago

Version

1.24.0

What did you expect to happen?

No warnings displayed

What actually happens?

Everything works fine locally but I see the following warning in the WP admin on Pantheon:

file_get_contents(/code/web/wp-content/themes/my_theme/.env): Failed to open stream: No such file or directory

I have an .env file in the app root and have been using Bedrock & Sage for years without issue. I tried changing $dotenv->load(); to $dotenv->safeLoad(); in application.php but it didn’t do anything. https://github.com/roots/bedrock/blob/23a184557bb04b0e1cff899346ee69ca456bff49/config/application.php#L42

Steps to reproduce

Open the WP admin (I’m using Query Monitor fwiw). The warning goes away if I downgrade to Acorn 3.

System info

PHP 8.2, WP 6.5.3, Sage 10, Acorn 4.2.2, and the following Composer deps:

"php": ">=8.2",
"composer/installers": "^2.2.0",
"ffraenz/private-composer-installer": "^5.0",
"filp/whoops": "^2.14",
"johnbillion/extended-cpts": "^5.0.7",
"log1x/navi": "^3.0.0",
"oscarotero/env": "^2.1",
"pantheon-systems/quicksilver-pushback": "^2.0",
"pantheon-systems/wordpress-composer": "~6.5.2",
"roots/acorn": "^4.2.2",
"roots/acorn-prettify": "^1.0.1",
"roots/bedrock-autoloader": "^1.0",
"roots/bedrock-disallow-indexing": "^2.0",
"roots/wp-config": "1.0.0",
"roots/wp-password-bcrypt": "^1.1.0",
"vlucas/phpdotenv": "^5.4",

Log output

/code/vendor/vlucas/phpdotenv/src/Store/File/Reader.php:73
file_get_contents()
/code/vendor/vlucas/phpdotenv/src/Store/File/Reader.php:73
Dotenv\S\F\Reader::readFromFile()
/code/vendor/vlucas/phpdotenv/src/Store/File/Reader.php:48
Dotenv\S\F\Reader::read()
/code/vendor/vlucas/phpdotenv/src/Store/FileStore.php:62
Dotenv\Store\FileStore->read()
/code/vendor/vlucas/phpdotenv/src/Dotenv.php:222
Dotenv\Dotenv->load()
/code/vendor/vlucas/phpdotenv/src/Dotenv.php:237
Dotenv\Dotenv->safeLoad()
/code/vendor/roots/acorn/src/Illuminate/Foundation/Bootstrap/LoadEnvironmentVariables.php:29
Illuminate\F\B\LoadEnvironmentVariables->bootstrap()
/code/vendor/roots/acorn/src/Illuminate/Foundation/Application.php:263
Illuminate\Foundation\Application->bootstrapWith()
/code/vendor/roots/acorn/src/Illuminate/Foundation/Http/Kernel.php:186
Illuminate\F\H\Kernel->bootstrap()
/code/vendor/roots/acorn/src/Roots/Acorn/Bootloader.php:187
Roots\Acorn\Bootloader->bootHttp()
/code/vendor/roots/acorn/src/Roots/Acorn/Bootloader.php:103
Roots\Acorn\Bootloader->boot()
wp-content/themes/my_theme/functions.php:43

Please confirm this isn't a support request.

Yes

tedw commented 4 months ago

I should note that this doesn’t appear to be impacting the site’s functionality but I would really like to get rid of this warning if possible.

Let me know if you think this is more likely an Acorn issue and I will submit there instead. Thanks!

tedw commented 4 weeks ago

After upgrading to the latest version of Acorn and adding an empty .env file to the theme folder I no longer get the warning.

retlehs commented 4 weeks ago

Cross referencing this since it's possibly related: https://github.com/roots/acorn/issues/380