{"record":{"id":"c3682625b6c92a55","repo":"hashicorp/nomad","slug":"failed-check-for-macos-jvm-v-out-v","errorCode":null,"errorMessage":"failed check for macOS jvm: %v, out: %v","messagePattern":"failed check for macOS jvm: (.+?), out: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/java/utils.go","lineNumber":26,"sourceCode":"\t\"fmt\"\n\t\"os/exec\"\n\t\"regexp\"\n\trt \"runtime\"\n\t\"strings\"\n)\n\nvar javaVersionCommand = []string{\"java\", \"-version\"}\nvar macOSJavaTestCommand = \"/usr/libexec/java_home\"\n\nfunc checkForMacJVM() (ok bool, err error) {\n\t// test for java differently because of the shim application\n\tvar out bytes.Buffer\n\tcmd := exec.Command(macOSJavaTestCommand)\n\tcmd.Stdout = &out\n\tcmd.Stderr = &out\n\terr = cmd.Run()\n\tif err != nil {\n\t\terr = fmt.Errorf(\"failed check for macOS jvm: %v, out: %v\", err, strings.ReplaceAll(strings.ReplaceAll(out.String(), \"\\n\", \" \"), `\"`, `\\\"`))\n\t\treturn false, err\n\t}\n\treturn true, nil\n}\n\nfunc javaVersionInfo() (version, runtime, vm string, err error) {\n\tvar out bytes.Buffer\n\n\tif rt.GOOS == \"darwin\" {\n\t\t_, err = checkForMacJVM()\n\t\tif err != nil {\n\t\t\terr = fmt.Errorf(\"failed to check java version: %v\", err)\n\t\t\treturn\n\t\t}\n\t}\n\n\tcmd := exec.Command(javaVersionCommand[0], javaVersionCommand[1:]...)\n\tcmd.Stdout = &out","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/java/utils.go#L8-L44","documentation":"On darwin, the driver probes for a JVM by running macOSJavaTestCommand (an external shell command) and capturing combined output. If that command exits non-zero, checkForMacJVM fails with this error, embedding both the exec error and the command output (with quotes/newlines escaped). It propagates up wrapped by 'failed to check java version'.","triggerScenarios":"javaVersionInfo() on macOS invokes checkForMacJVM; the probe command (e.g. /usr/libexec/java_home) fails — no JVM installed, Xcode command-line tools missing, or the helper returns an error.","commonSituations":"Mac Nomad client without a JDK; /usr/libexec/java_home failing after a macOS upgrade; java_home returning 'Unable to find any JVMs matching version'; corrupt JAVA_HOME.","solutions":["Install a JDK on the macOS host (brew install --cask temurin) so the java_home probe succeeds.","Run the probe command manually (/usr/libexec/java_home -V) and read the embedded 'out:' text in the error for the exact reason.","Point JAVA_HOME at a valid JDK or reinstall after an OS upgrade."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if runtime.GOOS == \"darwin\" {\n    if out, err := exec.Command(\"/usr/libexec/java_home\", \"-V\").CombinedOutput(); err != nil {\n        return fmt.Errorf(\"no macOS JVM: %v: %s\", err, out)\n    }\n}","typeGuard":null,"tryCatchPattern":"ok, err := checkForMacJVM()\nif err != nil {\n    // err already embeds probe output; log and mark driver unhealthy\n    logger.Error(\"macOS JVM probe failed\", \"error\", err)\n    return\n}","preventionTips":["Install a JDK (brew install --cask temurin) on macOS Nomad clients.","Re-check JAVA_HOME after macOS or JDK upgrades.","Run /usr/libexec/java_home manually to confirm the probe passes."],"tags":["nomad","java-driver","macos","jvm-detection","fingerprint"],"backgroundTag":"jvm-not-detected","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}