{"record":{"id":"5c719666d9480671","repo":"apache/beam","slug":"could-not-create-a-temporary-directory-for-storing","errorCode":null,"errorMessage":"Could not create a temporary directory for storing credentials: {credentialsDir.getAbsolutePath()}","messagePattern":"Could not create a temporary directory for storing credentials: (.+?)","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":98,"sourceCode":"    try (FileOutputStream fout = new FileOutputStream(dockerComposeFile)) {\n      ByteStreams.copy(getClass().getResourceAsStream(\"/docker-compose.yml\"), fout);\n    }\n\n    File envFile = Paths.get(tmpDir, \".env\").toFile();\n    try (FileOutputStream fout = new FileOutputStream(envFile)) {\n      ByteStreams.copy(getClass().getResourceAsStream(\"/.env\"), fout);\n    }\n\n    // Setting up the credentials directory.\n    File credentialsDir = Paths.get(tmpDir, \"credentials_dir\").toFile();\n    if (credentialsDir.exists()) {\n      LOG.info(\"Reusing the existing credentials directory {}\", credentialsDir.getAbsolutePath());\n    } else {\n      LOG.info(\n          \"Creating a temporary directory for storing credentials: {}\",\n          credentialsDir.getAbsolutePath());\n      if (!credentialsDir.mkdir()) {\n        throw new IOException(\n            \"Could not create a temporary directory for storing credentials: \"\n                + credentialsDir.getAbsolutePath());\n      }\n\n      LOG.info(\"Copying the Google Application Default Credentials file.\");\n\n      File applicationDefaultCredentialsFileCopied =\n          Paths.get(credentialsDir.getAbsolutePath(), \"application_default_credentials.json\")\n              .toFile();\n\n      boolean isWindows =\n          System.getProperty(\"os.name\").toLowerCase(Locale.ENGLISH).contains(\"windows\");\n      String applicationDefaultFilePathSuffix =\n          isWindows\n              ? \"\\\\gcloud\\\\application_default_credentials.json\"\n              : \"/.config/gcloud/application_default_credentials.json\";\n      String applicationDefaultFilePath =\n          System.getProperty(\"user.home\") + applicationDefaultFilePathSuffix;","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/transform-service/launcher/src/main/java/org/apache/beam/sdk/transformservice/launcher/TransformServiceLauncher.java#L80-L116","documentation":"TransformServiceLauncher's constructor prepares a directory to hold Google Application Default Credentials for the transform service. When the chosen directory does not exist and mkdir() fails (permissions, existing file at path, full disk), it throws an IOException with this message including the absolute path.","triggerScenarios":"Constructing TransformServiceLauncher when credentialsDir cannot be created: parent directory not writable, path already exists as a regular file, or filesystem is read-only/full.","commonSituations":"Running in a read-only container filesystem, TMPDIR pointing to a non-writable location, a stale file where the directory should be, and restricted service accounts without write access to the configured dir.","solutions":["Check/write-enable the parent directory or choose a writable credentialsDir.","Remove any regular file occupying the credentialsDir path.","Set a writable temp dir (e.g. TMPDIR=/tmp) when running in locked-down containers.","Verify available disk space and that the process user has write permission."],"exampleFix":"// before\nexport TMPDIR=/var/ro-tmp\n// after\nexport TMPDIR=/tmp && rm -f /tmp/transform-service-creds # if a stale file exists","handlingStrategy":"validation","validationCode":"File dir = new File(base, \"creds\"); if (!dir.exists() && !(dir.mkdirs() || dir.isDirectory())) { throw new IOException(\"cannot prepare credentials dir: \" + dir); }","typeGuard":null,"tryCatchPattern":"try { new TransformServiceLauncher(...); } catch (IOException e) { if (e.getMessage().contains(\"temporary directory\")) { /* fall back to an explicitly writable dir */ } throw e; }","preventionTips":["Point TMPDIR/credentials dir at a writable filesystem","Pre-create the directory with correct permissions in the container image","Ensure no regular file occupies the target path","Check disk space before launching"],"tags":["java","filesystem","credentials","io"],"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-20T03:17:13.778Z"}