{"record":{"id":"f96e3bc06f368dc4","repo":"hashicorp/nomad","slug":"failed-to-launch-command-with-executor-v-f96e3b","errorCode":null,"errorMessage":"failed to launch command with executor: %v","messagePattern":"failed to launch command with executor: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/java/driver.go","lineNumber":525,"sourceCode":"\t\tEnv:              cfg.EnvList(),\n\t\tUser:             user,\n\t\tResourceLimits:   true,\n\t\tResources:        cfg.Resources,\n\t\tTaskDir:          cfg.TaskDir().Dir,\n\t\tWorkDir:          driverConfig.WorkDir,\n\t\tStdoutPath:       cfg.StdoutPath,\n\t\tStderrPath:       cfg.StderrPath,\n\t\tMounts:           cfg.Mounts,\n\t\tDevices:          cfg.Devices,\n\t\tNetworkIsolation: cfg.NetworkIsolation,\n\t\tModePID:          executor.IsolationMode(d.config.DefaultModePID, driverConfig.ModePID),\n\t\tModeIPC:          executor.IsolationMode(d.config.DefaultModeIPC, driverConfig.ModeIPC),\n\t\tCapabilities:     caps,\n\t}\n\n\tps, err := exec.Launch(execCmd)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to launch command with executor: %v\", err)\n\t}\n\n\th := &taskHandle{\n\t\texec:         exec,\n\t\tpid:          ps.Pid,\n\t\tpluginClient: pluginClient,\n\t\ttaskConfig:   cfg,\n\t\tprocState:    drivers.TaskStateRunning,\n\t\tstartedAt:    time.Now().Round(time.Millisecond),\n\t\tlogger:       d.logger,\n\t}\n\n\tdriverState := TaskState{\n\t\tReattachConfig: pstructs.ReattachConfigFromGoPlugin(pluginClient.ReattachConfig()),\n\t\tPid:            ps.Pid,\n\t\tTaskConfig:     cfg,\n\t\tStartedAt:      h.startedAt,\n\t}","sourceCodeStart":507,"sourceCodeEnd":543,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/java/driver.go#L507-L543","documentation":"After the executor is created, StartTask calls exec.Launch(execCmd) to actually start the java command under isolation. Any failure launching the process — bad binary path, setuid/user switching failure, resource limit setup, namespace/cgroup setup on Linux, invalid mounts/devices/capabilities — is wrapped with this message. The java command was fully configured at this point, so the error usually reflects isolation/environment problems rather than job config syntax.","triggerScenarios":"Calling StartTask when exec.Launch fails: java binary path (absPath) unusable at exec time, task user (e.g. 'nobody') cannot be setuid'd, cgroups/namespace creation fails, chroot/mount setup fails, CapAdd beyond allowed caps, or stdout/stderr paths unwritable.","commonSituations":"Linux clients without proper cgroup setup or with seccomp/AppArmor restrictions; running Nomad in unprivileged Docker where isolation modes (ModePID/ModeIPC) are unsupported; caps_calculation passing but kernel denying capabilities at exec; task user missing on host; disk full preventing redirection of stdout/stderr files.","solutions":["Check the Nomad client debug log for the underlying Launch error (cgroup, mount, setuid) and address that root cause.","If running Nomad inside Docker, start the container with --privileged and proper mounts, or set driver java options to disable unsupported isolation (e.g. mode_pid/mode_ipc = \"private\" vs host defaults).","Verify the task user exists on the host (e.g. nobody) and Nomad has permission to switch users (root or CAP_SETUID).","Confirm the java binary path works and the alloc dir/stdout/stderr paths are writable; retry the allocation."],"exampleFix":"// before (Nomad in Docker, namespace setup fails)\ndocker run net=text nomad agent -dev\n// after\ndocker run --privileged -v /var/run/docker.sock:/var/run/docker.sock nomad agent -dev","handlingStrategy":"try-catch","validationCode":"// preflight the exec environment before Launch\nif user != \"\" {\n    if _, err := user2.Lookup(user); err != nil {\n        return fmt.Errorf(\"task user %q does not exist on host: %w\", user, err)\n    }\n}\nif _, err := os.Stat(absPath); err != nil {\n    return fmt.Errorf(\"java binary not executable at %s: %w\", absPath, err)\n}\nif err := unix.Access(filepath.Dir(cfg.StdoutPath), unix.W_OK); err != nil {\n    return fmt.Errorf(\"stdout/stderr path not writable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"_, _, err := driver.StartTask(cfg)\nif err != nil && strings.Contains(err.Error(), \"failed to launch command with executor\") {\n    // inspect client debug logs for cgroup/namespace/setuid root cause, then retry\n    return InspectClientAndRetry(fmt.Errorf(\"executor could not launch java process: %w\", err))\n}","preventionTips":["Run Nomad clients as root (or with CAP_SETUID/CAP_SYS_ADMIN) when using Linux isolation.","Don't run production clients inside unprivileged Docker; use --privileged or disable unsupported isolation modes.","Verify task users exist on the host and cgroup v1/v2 setup matches the Nomad version.","Keep disk space free on the client for stdout/stderr redirection.","Roll out cap_add/cap_drop changes gradually and test on a staging client."],"tags":["nomad","java-driver","executor","process-launch","isolation"],"backgroundTag":"executor-launch-failed","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"}