{"record":{"id":"b0f577281f460a42","repo":"elastic/elasticsearch","slug":"failed-to-read-etc-os-release","errorCode":null,"errorMessage":"Failed to read /etc/os-release","messagePattern":"Failed to read /etc/os-release","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/docker/DockerSupportService.java","lineNumber":252,"sourceCode":"        // Even if for some reason Docker exists on Windows agents, flag it as unsupported\n        if (OS.current() == OS.WINDOWS) {\n            return true;\n        }\n\n        // Only some hosts in CI are configured with Docker. We attempt to work out the OS\n        // and version, so that we know whether to expect to find Docker. We don't attempt\n        // to probe for whether Docker is available, because that doesn't tell us whether\n        // Docker is unavailable when it should be.\n        final Path osRelease = Paths.get(\"/etc/os-release\");\n\n        if (Files.exists(osRelease)) {\n            Map<String, String> values;\n\n            try {\n                final List<String> osReleaseLines = Files.readAllLines(osRelease);\n                values = parseOsRelease(osReleaseLines);\n            } catch (IOException e) {\n                throw new GradleException(\"Failed to read /etc/os-release\", e);\n            }\n\n            final String id = deriveId(values);\n            final boolean excluded = getLinuxExclusionList().contains(id);\n\n            if (excluded) {\n                LOGGER.warn(\"Linux OS id [{}] is present in the Docker exclude list. Tasks requiring Docker will be disabled.\", id);\n            }\n\n            return excluded;\n        }\n\n        return false;\n    }\n\n    private List<String> getLinuxExclusionList() {\n        File exclusionsFile = getParameters().getExclusionsFile();\n","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/docker/DockerSupportService.java#L234-L270","documentation":"Thrown by DockerSupportService.isExcludedOs() when reading /etc/os-release fails with an IOException. The build reads /etc/os-release to determine the Linux distribution ID (e.g., 'ubuntu-22.04') and checks it against the Docker exclusion list. Only reached when running in CI (getIsCI() == true) on a non-Windows Linux host. The IOException is wrapped in a GradleException with a static message.","triggerScenarios":"The build runs in CI (buildParams.getCi() is true), the OS is Linux (not Windows), /etc/os-release exists (Files.exists returns true), but Files.readAllLines throws IOException. This can happen if the file is a broken symlink, has restrictive permissions, or is on a filesystem that becomes unreadable mid-read.","commonSituations":"A CI container image lacks a properly mounted /etc/os-release or has it as an unreadable bind-mount. A minimal container (distroless, scratch-based) has a broken symlink at /etc/os-release pointing to /usr/lib/os-release which is missing. Filesystem corruption or a container runtime race condition during build startup.","solutions":["Verify /etc/os-release is a real, readable file: cat /etc/os-release inside the CI container.","If using a minimal container, ensure os-release is installed (e.g., apt-get install -y base-files on Debian/Ubuntu).","If the file is intentionally absent, ensure Files.exists returns false for it so the code path returns false (not excluded) instead of failing on read."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-flight check before Docker-dependent tasks\nPath osRelease = Paths.get(\"/etc/os-release\");\nif (Files.exists(osRelease) && !Files.isReadable(osRelease)) {\n    throw new GradleException(\"/etc/os-release exists but is not readable\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate /etc/os-release readability in CI container setup scripts.","Use Docker images that include a valid os-release file (e.g., official Ubuntu/Debian images).","In CI, log the OS identification early to catch missing os-release before task execution."],"tags":["docker","ci","linux","filesystem","io"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}