{"record":{"id":"1891006dfd97aa4f","repo":"jenkinsci/jenkins","slug":"process-working-directory-s-doesn-t-exist","errorCode":null,"errorMessage":"Process working directory '%s' doesn't exist!","messagePattern":"Process working directory '(.+?)' doesn't exist!","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/hudson/Proc.java","lineNumber":247,"sourceCode":"            if (env != null) {\n                Map<String, String> m = pb.environment();\n                m.clear();\n                for (String e : env) {\n                    int idx = e.indexOf('=');\n                    m.put(e.substring(0, idx), e.substring(idx + 1));\n                }\n            }\n            return pb;\n        }\n\n        private LocalProc(String name, ProcessBuilder procBuilder, InputStream in, OutputStream out, OutputStream err) throws IOException {\n            Logger.getLogger(Proc.class.getName()).log(Level.FINE, \"Running: {0}\", name);\n            this.name = name;\n            this.out = out;\n            this.cookie = EnvVars.createCookie();\n            procBuilder.environment().putAll(cookie);\n            if (procBuilder.directory() != null && !procBuilder.directory().exists()) {\n                throw new IOException(String.format(\"Process working directory '%s' doesn't exist!\", procBuilder.directory().getAbsolutePath()));\n            }\n            this.proc = procBuilder.start();\n\n            InputStream procInputStream = proc.getInputStream();\n            if (out == SELFPUMP_OUTPUT) {\n                stdout = procInputStream;\n                copier = null;\n            } else {\n                copier = new StreamCopyThread(name + \": stdout copier\", procInputStream, out);\n                copier.start();\n                stdout = null;\n            }\n\n            if (in == null) {\n                // nothing to feed to stdin\n                stdin = null;\n                proc.getOutputStream().close();\n            } else","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/jenkinsci/jenkins/blob/2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc/core/src/main/java/hudson/Proc.java#L229-L265","documentation":"Thrown in the LocalProc constructor when the ProcessBuilder's configured working directory exists as a path object but does not actually exist on the filesystem. The message includes the absolute path of the missing directory. This is a pre-launch guard before procBuilder.start() is called.","triggerScenarios":"A Launcher.LocalLauncher (or direct LocalProc instantiation) creates a ProcessBuilder with directory() set to a path, then checks procBuilder.directory().exists() — if false, it throws. The check runs after cookie/cookie env injection but before procBuilder.start().","commonSituations":"An agent's remote FS root (configured in node settings) points to a deleted or unmounted directory; a build step references a custom workspace path that was cleaned up by a previous build or never created; running on a Docker container where the mount point for the workspace is not present; a tool installer's home directory was removed.","solutions":["Verify the agent's 'Remote root directory' setting in Manage Jenkins → Nodes points to an existing, writable directory.","Ensure any custom workspace path passed to the launcher is created before launching the process (e.g., via a pre-build shell step that runs mkdir -p).","Check for external cleanup (cron jobs, disk cleanup plugins) that may have deleted the directory.","If running inside a container, verify the volume mount for the workspace is correctly configured and the mount point exists."],"exampleFix":"// before\nLauncher launcher = node.createLauncher(taskListener);\nlauncher.launch().cmds(cmds).pwd(workspacePath).start();\n\n// after\nif (!Files.exists(workspacePath)) {\n    Files.createDirectories(workspacePath);\n}\nLauncher launcher = node.createLauncher(taskListener);\nlauncher.launch().cmds(cmds).pwd(workspacePath).start();","handlingStrategy":"validation","validationCode":"// Validate working directory before launching\nPath workDir = node.getRootPath().toPath(); // or custom workspace\nif (!Files.exists(workDir)) {\n    Files.createDirectories(workDir);\n}\nLauncher launcher = node.createLauncher(listener);","typeGuard":null,"tryCatchPattern":"try {\n    proc = launcher.launch().cmds(cmds).pwd(workDir).start();\n} catch (IOException e) {\n    if (e.getMessage().contains(\"doesn't exist\")) {\n        // Recreate directory and retry once\n        Files.createDirectories(workDir);\n        proc = launcher.launch().cmds(cmds).pwd(workDir).start();\n    } else {\n        throw e;\n    }\n}","preventionTips":["Verify agent root directory exists and is writable during agent provisioning.","Use a pre-build step to ensure workspace directories exist (mkdir -p).","Monitor agent disk health — stale mounts and full disks can cause path issues."],"tags":["process","filesystem","agent","configuration","launcher"],"backgroundTag":null,"analyzedSha":"2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc","analyzedAt":"2026-08-14T07:07:15.274Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}