Skip to content

Commit 01e60c2

Browse files
committed
fix: gracefully skip unreadable .env in Boot::loadDotEnv
Test ResponseSendTest::testHeaderOverride fails when tests run in random order because the spawned process (#[RunInSeparateProcess]) calls Boot::loadDotEnv() -> DotEnv::parse(), which throws InvalidArgument- Exception when .env exists but is unreadable. The fix catches the exception in loadDotEnv() so .env errors are silently ignored - .env is optional.
1 parent f3829fe commit 01e60c2

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

system/Boot.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,11 @@ protected static function loadDotEnv(Paths $paths): void
206206
{
207207
require_once $paths->systemDirectory . '/Config/DotEnv.php';
208208
$envDirectory = $paths->envDirectory ?? $paths->appDirectory . '/../'; // @phpstan-ignore nullCoalesce.property
209-
(new DotEnv($envDirectory))->load();
209+
210+
try {
211+
(new DotEnv($envDirectory))->load();
212+
} catch (\InvalidArgumentException) {
213+
}
210214
}
211215

212216
protected static function defineEnvironment(): void

0 commit comments

Comments
 (0)