{"record":{"id":"a841f677521a3046","repo":"apache/beam","slug":"could-not-create-a-temporary-directory-for-storing-a841f6","errorCode":null,"errorMessage":"Could not create a temporary directory for storing dependencies: {dependenciesDir.getAbsolutePath()}","messagePattern":"Could not create a temporary directory for storing dependencies: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"sdks/java/transform-service/launcher/src/main/java/org/apache/beam/sdk/transformservice/launcher/TransformServiceLauncher.java","lineNumber":140,"sourceCode":"        LOG.error(\n            \"GCP credentials will not be available for the transform service since the Google \"\n                + \"Cloud application default credentials file could not be found at the expected \"\n                + \"location {}.\",\n            applicationDefaultFilePath);\n      }\n    }\n\n    // Setting up the dependencies directory.\n    File dependenciesDir = Paths.get(tmpDir, \"dependencies_dir\").toFile();\n    Path updatedRequirementsFilePath = Paths.get(dependenciesDir.toString(), \"requirements.txt\");\n    if (dependenciesDir.exists()) {\n      LOG.info(\"Reusing the existing dependencies directory {}\", dependenciesDir.getAbsolutePath());\n    } else {\n      LOG.info(\n          \"Creating a temporary directory for storing dependencies: {}\",\n          dependenciesDir.getAbsolutePath());\n      if (!dependenciesDir.mkdir()) {\n        throw new IOException(\n            \"Could not create a temporary directory for storing dependencies: \"\n                + dependenciesDir.getAbsolutePath());\n      }\n\n      // We create a requirements file with extra dependencies.\n      // If there are no extra dependencies, we just provide an empty requirements file.\n      File file = updatedRequirementsFilePath.toFile();\n      if (!file.createNewFile()) {\n        throw new IOException(\n            \"Could not create the new requirements file \" + updatedRequirementsFilePath);\n      }\n\n      // Updating dependencies.\n      if (pythonRequirementsFile != null) {\n        Path requirementsFilePath = Paths.get(pythonRequirementsFile);\n        List<String> updatedLines = new ArrayList<>();\n\n        try (Stream<String> lines = java.nio.file.Files.lines(requirementsFilePath)) {","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/transform-service/launcher/src/main/java/org/apache/beam/sdk/transformservice/launcher/TransformServiceLauncher.java#L122-L158","documentation":"Thrown by TransformServiceLauncher when it fails to create the temporary local directory used to stage extra dependencies (pythonRequirementsFile staging dir) before launching the Beam Transform Service. File.mkdir() returns false (instead of throwing) when the parent directory does not exist or the process lacks write permission on it, and the launcher converts that into this IOException. Without this directory the launcher cannot write the updated requirements file or the DEPENDENCIES_VOLUME mount, so startup is aborted.","triggerScenarios":"Calling TransformServiceLauncher's public startup path (e.g. via main/expand flows) when dependenciesDir already does not exist AND File.mkdir() fails: the parent directory of dependenciesDir is missing, the filesystem is read-only, or the user lacks write permission at that location.","commonSituations":"Running the launcher in a container or CI environment where the default temp path is read-only or mounted noexec; a custom dependencies directory passed whose parent does not exist; running as a non-root user without write access to the configured directory; disk full on the staging volume.","solutions":["Create the parent directory of dependenciesDir first (Files.createDirectories on the parent), since mkdir() does not create intermediate directories.","Check filesystem permissions/write access for the user running the launcher and pick a writable location (e.g. java.io.tmpdir).","Verify the volume backing the path is writable (not read-only mount, not out of disk space)."],"exampleFix":"// before: parent does not exist, mkdir() fails\nPath deps = Paths.get(\"/opt/beam/transforms/deps\");\nservice.launch(deps);\n\n// after: ensure parents exist first\nFiles.createDirectories(Paths.get(\"/opt/beam/transforms/deps\"));","handlingStrategy":"validation","validationCode":"Path deps = Paths.get(dependenciesDirPath);\nif (java.nio.file.Files.exists(deps) && !java.nio.file.Files.isDirectory(deps))\n  throw new IllegalStateException(\"dependencies path is not a directory\");\nif (!java.nio.file.Files.exists(deps))\n  java.nio.file.Files.createDirectories(deps.getParent() == null ? deps : deps.getParent());\nif (!java.nio.file.Files.isWritable(java.nio.file.Files.exists(deps) ? deps : deps.getParent()))\n  throw new IllegalStateException(\"no write permission for dependencies directory\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use Files.createDirectories (creates parents) instead of relying on mkdir().","Run the launcher as a user with write access to the staging location.","Prefer java.io.tmpdir or another guaranteed-writable volume in containers."],"tags":["java","io","filesystem","directory-creation"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}