GoogleContainerTools/jib · error · NoSuchFileException
${file}
Error message
${file} What it means
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.
Source
Thrown at jib-core/src/main/java/com/google/cloud/tools/jib/api/JavaContainerBuilder.java:301
*/
public JavaContainerBuilder setOthersDestination(RelativeUnixPath othersDestination) {
this.othersDestination = othersDestination;
return this;
}
/**
* Adds dependency JARs to the image. Duplicate JAR filenames across all dependencies are renamed
* with the filesize in order to avoid collisions.
*
* @param dependencyFiles the list of dependency JARs to add to the image
* @return this
* @throws IOException if adding the layer fails
*/
public JavaContainerBuilder addDependencies(List<Path> dependencyFiles) throws IOException {
// Make sure all files exist before adding any
for (Path file : dependencyFiles) {
if (!Files.exists(file)) {
throw new NoSuchFileException(file.toString());
}
}
addedDependencies.addAll(dependencyFiles);
classpathOrder.add(LayerType.DEPENDENCIES);
return this;
}
/**
* Adds dependency JARs to the image. Duplicate JAR filenames across all dependencies are renamed
* with the filesize in order to avoid collisions.
*
* @param dependencyFiles the list of dependency JARs to add to the image
* @return this
* @throws IOException if adding the layer fails
*/
public JavaContainerBuilder addDependencies(Path... dependencyFiles) throws IOException {
return addDependencies(Arrays.asList(dependencyFiles));
}View on GitHub (pinned to fb949e2676)
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
Example fix
// before javaContainerBuilder.addDependencies(dependencyFiles); // after List<Path> existing = dependencyFiles.stream().filter(Files::exists).collect(Collectors.toList()); javaContainerBuilder.addDependencies(existing);
Defensive patterns
Strategy: validation
Validate before calling
List<Path> missing = dependencyFiles.stream().filter(p -> !Files.exists(p)).collect(Collectors.toList()); if (!missing.isEmpty()) throw new IllegalStateException("Missing deps: " + missing); Type guard
Predicate<Path> exists = p -> p != null && Files.exists(p);
Try / catch
try { builder.addDependencies(files); } catch (NoSuchFileException e) { log.error("Dependency file missing: {}", e.getFile()); } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- extraDirectories.paths contain "from" directory that doesn't
- extraDirectories.paths contain "from" directory that doesn't
- <extraDirectories><paths> contain "from" directory that does
- <extraDirectories><paths> contain "from" directory that does
- <extraDirectories><paths> contain "from" directory that does
AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06).
Data as JSON: /api/errors/54919a4dc139bfba.
Report an issue: GitHub.