{"record":{"id":"d546e57a365931e2","repo":"GoogleContainerTools/jib","slug":"unable-to-create-cache-directory-for-project-path","errorCode":null,"errorMessage":"Unable to create cache directory for project path: ${path} - you can try to configure --project-cache manually","messagePattern":"Unable to create cache directory for project path: (.+?) - you can try to configure --project-cache manually","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"jib-cli/src/main/java/com/google/cloud/tools/jib/cli/CacheDirectories.java","lineNumber":75,"sourceCode":"                Paths.get(System.getProperty(\"java.io.tmpdir\"))\n                    .resolve(\"jib-cli-cache\")\n                    .resolve(\"projects\")\n                    .resolve(getProjectCacheDirectoryFromProject(contextRoot))));\n  }\n\n  @VisibleForTesting\n  static String getProjectCacheDirectoryFromProject(Path path) {\n    try {\n      byte[] hashedBytes =\n          MessageDigest.getInstance(\"SHA-256\")\n              .digest(path.toFile().getCanonicalPath().getBytes(Charsets.UTF_8));\n      StringBuilder stringBuilder = new StringBuilder(2 * hashedBytes.length);\n      for (byte b : hashedBytes) {\n        stringBuilder.append(String.format(\"%02x\", b));\n      }\n      return stringBuilder.toString();\n    } catch (IOException | SecurityException ex) {\n      throw new RuntimeException(\n          \"Unable to create cache directory for project path: \"\n              + path\n              + \" - you can try to configure --project-cache manually\",\n          ex);\n    } catch (NoSuchAlgorithmException ex) {\n      throw new RuntimeException(\n          \"SHA-256 algorithm implementation not found - might be a broken JVM\");\n    }\n  }\n\n  public CacheDirectories(@Nullable Path baseImageCache, Path projectCache) {\n    this.baseImageCache = baseImageCache;\n    this.projectCache = projectCache;\n  }\n\n  public Optional<Path> getBaseImageCache() {\n    return Optional.ofNullable(baseImageCache);\n  }","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-cli/src/main/java/com/google/cloud/tools/jib/cli/CacheDirectories.java#L57-L93","documentation":"Jib CLI computes a hash of the project path and creates a per-project cache directory under the base cache location. If creating that directory throws an IOException or SecurityException, it wraps the failure in a RuntimeException with this message. It tells you the CLI could not materialize its local build cache for your project and suggests setting --project-cache manually.","triggerScenarios":"Calling CacheDirectories.getProjectCacheDirectoryFromProject (via from) when Files.createDirectories on the derived cache path throws IOException (e.g. parent dir not writable, disk full, path too long) or SecurityException (security manager denies write).","commonSituations":"Read-only home or shared cache directory, running in a container as non-root with unwritable /home, NFS-mounted cache location with permission issues, overly restrictive SecurityManager in CI.","solutions":["Pass --project-cache=/some/writable/path to point the cache at a writable directory.","Check and fix permissions on the default cache location (usually under the user home) so the process can create directories there.","Ensure sufficient disk space and that no file exists where the cache directory should be created.","If running under a SecurityManager, grant write permission to the cache path or disable it."],"exampleFix":"// before\njib ... // uses default cache under unwritable $HOME/.cache\n// after\njib ... --project-cache=/tmp/jib-cache","handlingStrategy":"fallback","validationCode":"Path cache = Paths.get(System.getProperty(\"user.home\"), \".cache\", \"jib\");\nif (!Files.isWritable(cache)) {\n  args.add(\"--project-cache=/tmp/jib-cache\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  runJib(args);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Unable to create cache directory\")) {\n    runJib(withProjectCache(args, \"/tmp/jib-cache\"));\n  } else throw e;\n}","preventionTips":["Always run Jib in an environment with a writable user home or explicit --project-cache","Set --project-cache in CI containers running as non-root","Monitor disk space on cache volumes"],"tags":["filesystem","cache","permissions","cli"],"backgroundTag":"file-write-failed","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}