{"record":{"id":"54919a4dc139bfba","repo":"GoogleContainerTools/jib","slug":"file","errorCode":null,"errorMessage":"${file}","messagePattern":"\\$\\{file\\}","errorType":"exception","errorClass":"NoSuchFileException","httpStatus":null,"severity":"error","filePath":"jib-core/src/main/java/com/google/cloud/tools/jib/api/JavaContainerBuilder.java","lineNumber":301,"sourceCode":"   */\n  public JavaContainerBuilder setOthersDestination(RelativeUnixPath othersDestination) {\n    this.othersDestination = othersDestination;\n    return this;\n  }\n\n  /**\n   * Adds dependency JARs to the image. Duplicate JAR filenames across all dependencies are renamed\n   * with the filesize in order to avoid collisions.\n   *\n   * @param dependencyFiles the list of dependency JARs to add to the image\n   * @return this\n   * @throws IOException if adding the layer fails\n   */\n  public JavaContainerBuilder addDependencies(List<Path> dependencyFiles) throws IOException {\n    // Make sure all files exist before adding any\n    for (Path file : dependencyFiles) {\n      if (!Files.exists(file)) {\n        throw new NoSuchFileException(file.toString());\n      }\n    }\n    addedDependencies.addAll(dependencyFiles);\n    classpathOrder.add(LayerType.DEPENDENCIES);\n    return this;\n  }\n\n  /**\n   * Adds dependency JARs to the image. Duplicate JAR filenames across all dependencies are renamed\n   * with the filesize in order to avoid collisions.\n   *\n   * @param dependencyFiles the list of dependency JARs to add to the image\n   * @return this\n   * @throws IOException if adding the layer fails\n   */\n  public JavaContainerBuilder addDependencies(Path... dependencyFiles) throws IOException {\n    return addDependencies(Arrays.asList(dependencyFiles));\n  }","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-core/src/main/java/com/google/cloud/tools/jib/api/JavaContainerBuilder.java#L283-L319","documentation":"JavaContainerBuilder.addDependencies checks that every path in the dependency list exists before adding any of them, throwing NoSuchFileException (an IOException) naming the missing file. It fails fast so you never build an image with a half-registered dependency list.","triggerScenarios":"Calling addDependencies with a List<Path> containing a file that does not exist on disk — a path with a typo, a file deleted before the build, or a path relative to the wrong working directory.","commonSituations":"Maven/Gradle plugins passing resolved artifact paths that were cleaned; scripts building the dependency list with stale or wrong-relative paths; files removed between collection and container build.","solutions":["Verify each path exists (Files.exists) before calling addDependencies","Convert relative paths to absolute against the correct base directory","Rebuild/refresh the dependency list so it reflects current artifacts","Catch NoSuchFileException and report which dependency file is missing"],"exampleFix":"// before\njavaContainerBuilder.addDependencies(dependencyFiles);\n// after\nList<Path> existing = dependencyFiles.stream().filter(Files::exists).collect(Collectors.toList());\njavaContainerBuilder.addDependencies(existing);","handlingStrategy":"validation","validationCode":"List<Path> missing = dependencyFiles.stream().filter(p -> !Files.exists(p)).collect(Collectors.toList()); if (!missing.isEmpty()) throw new IllegalStateException(\"Missing deps: \" + missing);","typeGuard":"Predicate<Path> exists = p -> p != null && Files.exists(p);","tryCatchPattern":"try { builder.addDependencies(files); } catch (NoSuchFileException e) { log.error(\"Dependency file missing: {}\", e.getFile()); }","preventionTips":["Check Files.exists on each dependency before the call","Use absolute paths resolved against the project base dir","Re-resolve artifacts (e.g. Maven dependency:list) instead of caching paths"],"tags":["file-not-found","jib","dependencies"],"backgroundTag":"file-not-found","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"}