{"record":{"id":"6f5ae8f317dbfa30","repo":"elastic/elasticsearch","slug":"can-t-determine-os-from-os","errorCode":null,"errorMessage":"Can't determine OS from: ${os}","messagePattern":"Can't determine OS from: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/OS.java","lineNumber":40,"sourceCode":"    public final String javaOsReference;\n\n    OS(String javaOsReference) {\n        // This constructor is intentionally empty, but it can be used to set up any necessary state.\n        this.javaOsReference = javaOsReference;\n    }\n\n    public static OS current() {\n        String os = System.getProperty(\"os.name\", \"\");\n        if (os.startsWith(\"Windows\")) {\n            return OS.WINDOWS;\n        }\n        if (os.startsWith(\"Linux\") || os.startsWith(\"LINUX\")) {\n            return OS.LINUX;\n        }\n        if (os.startsWith(\"Mac\")) {\n            return OS.MAC;\n        }\n        throw new IllegalStateException(\"Can't determine OS from: \" + os);\n    }\n\n    public static class Conditional<T> {\n\n        private final Map<OS, Supplier<T>> conditions = new EnumMap<>(OS.class);\n\n        public Conditional<T> onWindows(Supplier<T> supplier) {\n            conditions.put(WINDOWS, supplier);\n            return this;\n        }\n\n        public Conditional<T> onLinux(Supplier<T> supplier) {\n            conditions.put(LINUX, supplier);\n            return this;\n        }\n\n        public Conditional<T> onMac(Supplier<T> supplier) {\n            conditions.put(MAC, supplier);","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/OS.java#L22-L58","documentation":"OS.current() throws IllegalStateException when the JVM's os.name system property does not start with 'Windows', 'Linux'/'LINUX', or 'Mac'. The Elasticsearch build only supports Windows, Linux, and macOS; any other OS (AIX, FreeBSD, Solaris, z/OS, etc.) is rejected because the build toolchain, native tooling, and distribution packaging have no code paths for it.","triggerScenarios":"Any code path that calls OS.current() (directly or via OS.conditional().supply(), which internally calls current()). This runs eagerly at class-load for CURRENT_PLATFORM in ElasticsearchDistribution and is hit broadly across build-tools.","commonSituations":"Running the Elasticsearch build on an unsupported OS (FreeBSD, AIX, SmartOS); a container or CI image reporting an unexpected os.name; a JVM that returns a non-standard os.name string (rare); running under a compatibility layer that masks the OS name.","solutions":["Run the build on a supported OS: Linux, macOS, or Windows.","If on a supported OS, check System.getProperty('os.name') — a custom JVM or launcher may be reporting an unexpected value.","For CI, use a standard Linux or macOS image.","If you must build on an unsupported OS, you are on your own; consider cross-building in a supported container."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"String osName = System.getProperty(\"os.name\", \"\");\nif (!osName.startsWith(\"Windows\") && !osName.startsWith(\"Linux\") && !osName.startsWith(\"LINUX\") && !osName.startsWith(\"Mac\")) {\n    throw new IllegalStateException(\"Unsupported os.name: \" + osName + \"; use Linux, macOS, or Windows\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run the Elasticsearch build only on Linux, macOS, or Windows.","In CI, use standard Linux or macOS images.","If os.name looks wrong on a supported OS, investigate the JVM/launcher reporting it."],"tags":["gradle","build-tools","os-detection","environment"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}