{"record":{"id":"067d4f1e8eab78c1","repo":"jenkinsci/jenkins","slug":"failed-to-mkdirs-remote","errorCode":null,"errorMessage":"Failed to mkdirs: ${remote}","messagePattern":"Failed to mkdirs: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/hudson/FilePath.java","lineNumber":1401,"sourceCode":"     */\n    public @CheckForNull Computer toComputer() {\n        Jenkins j = Jenkins.getInstanceOrNull();\n        if (j != null) {\n            for (Computer c : j.getComputers()) {\n                if (getChannel() == c.getChannel()) {\n                    return c;\n                }\n            }\n        }\n        return null;\n    }\n\n    /**\n     * Creates this directory.\n     */\n    public void mkdirs() throws IOException, InterruptedException {\n        if (!act(new Mkdirs())) {\n            throw new IOException(\"Failed to mkdirs: \" + remote);\n        }\n    }\n\n    private static class Mkdirs extends MasterToSlaveFileCallable<Boolean> {\n        private static final long serialVersionUID = 1L;\n\n        @Override\n        public Boolean invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {\n            if (mkdirs(f) || f.exists())\n                return true;    // OK\n\n            // following Ant <mkdir> task to avoid possible race condition.\n            Thread.sleep(10);\n\n            return mkdirs(f) || f.exists();\n        }\n    }\n","sourceCodeStart":1383,"sourceCodeEnd":1419,"githubUrl":"https://github.com/jenkinsci/jenkins/blob/2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc/core/src/main/java/hudson/FilePath.java#L1383-L1419","documentation":"Thrown by FilePath.mkdirs() when act(new Mkdirs()) returns false, meaning File.mkdirs on the remote/local target failed without throwing (e.g., a parent is a file, or permission denied). The Mkdirs callable also accepts the case where the path already exists, so a false return means creation genuinely could not succeed.","triggerScenarios":"A parent path component is a regular file, not a directory; permission denied on a parent; read-only filesystem; path is invalid on the target OS; the target root does not exist and cannot be created.","commonSituations":"Workspace root configured under a file path; agent running under a user lacking write permission; Docker/container with a read-only mount; Windows path with illegal characters.","solutions":["Check that no parent component of the path is a file; remove or relocate it.","Verify write permission on the agent for the target directory and its parents.","Ensure the configured workspace/root path is valid and the mount is writable.","Create parent directories with appropriate ownership before invoking mkdirs."],"exampleFix":"null","handlingStrategy":"validation","validationCode":"// before mkdirs, ensure no parent is a file and dirs are writable\nPath p = Paths.get(remote);\nFiles.walk(p.getRoot() == null ? p : p.getRoot())\n     .filter(Files::isRegularFile)\n     .forEach(f -> { if (p.startsWith(f)) throw new IllegalStateException(f + \" is a file blocking mkdirs\"); });","typeGuard":"null","tryCatchPattern":"try {\n    fp.mkdirs();\n} catch (IOException e) {\n    // 'Failed to mkdirs' — verify permissions/parents, then retry or fail soft\n}","preventionTips":["Verify the workspace root path is a directory (not a file) before use.","Ensure the agent user owns or can write the workspace tree.","Avoid read-only mounts for writable workspace locations."],"tags":["filesystem","mkdirs","permissions"],"backgroundTag":null,"analyzedSha":"2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc","analyzedAt":"2026-08-14T07:07:15.274Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}