1
0
Fork 0

Fix docker detection breaking on constrained environments, fixes #12095

pull/11956/merge
Jordi Boggiano 2024-09-02 10:24:23 +02:00
parent 4a34725682
commit 1fcb6a5d53
No known key found for this signature in database
1 changed files with 8 additions and 2 deletions

View File

@ -197,7 +197,13 @@ class Platform
if (!is_readable($cgroup)) { if (!is_readable($cgroup)) {
continue; continue;
} }
$data = file_get_contents($cgroup); // suppress errors as some environments have these files as readable but system restrictions prevent the read from succeeding
// see https://github.com/composer/composer/issues/12095
try {
$data = @file_get_contents($cgroup);
} catch (\Throwable $e) {
break;
}
if (is_string($data) && str_contains($data, '/var/lib/docker/')) { if (is_string($data) && str_contains($data, '/var/lib/docker/')) {
return self::$isDocker = true; return self::$isDocker = true;
} }