{"record":{"id":"4015135f5c7ccf13","repo":"NationalSecurityAgency/ghidra","slug":"unable-to-create-temp-directory-dir-getabsolutep","errorCode":null,"errorMessage":"Unable to create temp directory: {dir.getAbsolutePath()}","messagePattern":"Unable to create temp directory: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BulkSignatures.java","lineNumber":1029,"sourceCode":"\t\t}\n\t}\n\n\tprotected File establishTemporaryDirectory(String xmldir) throws IOException {\n\t\tFile dir;\n\t\tif (xmldir == null) {\n\t\t\tFile tmpDir = Application.getUserTempDirectory();\n\t\t\tif (tmpDir == null) {\n\t\t\t\tthrow new IOException(\"Could not find temporary directory\");\n\t\t\t}\n\t\t\tdir = new File(tmpDir, \"bulkinsert_xml\");\n\t\t\tdeleteTemporaryDirectory(dir);\n\t\t}\n\t\telse {\n\t\t\tdir = new File(xmldir);\n\t\t}\n\t\tif (dir.exists() == false) {\n\t\t\tif (dir.mkdir() == false) {\n\t\t\t\tthrow new IOException(\"Unable to create temp directory: \" + dir.getAbsolutePath());\n\t\t\t}\n\t\t}\n\t\telse if (dir.isDirectory() == false) {\n\t\t\tthrow new IOException(dir.getAbsolutePath() + \": is not a directory\");\n\t\t}\n\t\tdir = dir.getCanonicalFile();\n\t\treturn dir;\n\t}\n\n\tprivate void deleteTemporaryDirectory(File tempDir) throws IOException {\n\t\tif (!tempDir.exists()) {\n\t\t\treturn;\n\t\t}\n\t\tFile[] listFiles = tempDir.listFiles();\n\t\tif (listFiles == null) {\n\t\t\tthrow new IOException(\n\t\t\t\t\"Could not list files in temp directory: \" + tempDir.getAbsolutePath());\n\t\t}","sourceCodeStart":1011,"sourceCodeEnd":1047,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BulkSignatures.java#L1011-L1047","documentation":"Thrown by establishTemporaryDirectory when dir.mkdir() returns false, meaning the operating system refused to create the directory. This is a filesystem-level failure — typically permissions, a parent that doesn't exist, or a name collision. Note mkdir() only creates one level; it does not create parents.","triggerScenarios":"The target directory path has a parent that doesn't exist (mkdir doesn't create parents); the parent directory is not writable by the current user; a file with the same name already exists at that path; disk is full or the filesystem is read-only.","commonSituations":"Running BSim tools as a user without write access to the parent directory; the temp directory path derived from a misconfigured setting; a previous run left a file (not directory) at the expected path; running on a read-only filesystem or full disk.","solutions":["Check write permissions on the parent directory.","Use mkdirs() instead of mkdir() if parent directories may be missing.","Verify the path doesn't already contain a regular file with the same name.","Check available disk space on the target volume."],"exampleFix":"// before\nif (dir.mkdir() == false) {\n    throw new IOException(\"Unable to create temp directory: \" + dir.getAbsolutePath());\n}\n\n// after — create parents, report cause\nif (!dir.exists() && !dir.mkdirs()) {\n    throw new IOException(\"Unable to create temp directory: \" + dir.getAbsolutePath() +\n        \" (parent exists: \" + dir.getParentFile() != null &&\n        dir.getParentFile().exists() + \", writable: \" +\n        (dir.getParentFile() != null && dir.getParentFile().canWrite()) + \")\");\n}","handlingStrategy":"validation","validationCode":"// Verify the parent directory is writable before attempting mkdir\nFile parent = dir.getParentFile();\nif (parent != null && !parent.exists()) {\n    parent.mkdirs(); // create missing parents\n}\nif (parent != null && !parent.canWrite()) {\n    throw new IllegalStateException(\n        \"Cannot write to parent directory: \" + parent.getAbsolutePath());\n}","typeGuard":"public static boolean canCreateDirectory(File dir) {\n    File parent = dir.getParentFile();\n    return dir != null && parent != null &&\n        (dir.exists() ? dir.isDirectory() : parent.canWrite());\n}","tryCatchPattern":"try {\n    File dir = bulk.establishTemporaryDirectory(xmldir);\n} catch (IOException e) {\n    if (e.getMessage().contains(\"Unable to create temp directory\")) {\n        // Try a different location\n        File dir = bulk.establishTemporaryDirectory(System.getProperty(\"user.home\") + \"/.bsim_tmp\");\n    } else {\n        throw e;\n    }\n}","preventionTips":["Check parent directory write permissions before creating subdirectories.","Use mkdirs() instead of mkdir() when parent directories may not exist.","Verify available disk space on the target volume.","Run BSim tools with appropriate user privileges."],"tags":["bsim","file-io","temp-directory","permissions"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}