{"record":{"id":"fae28a4b488c6021","repo":"GoogleContainerTools/jib","slug":"cannot-create-filelayers-from-non-file-non-direct","errorCode":null,"errorMessage":"Cannot create FileLayers from non-file, non-directory: ${src}","messagePattern":"Cannot create FileLayers from non-file, non-directory: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/Layers.java","lineNumber":82,"sourceCode":"      // each loop is a new layer\n      if (entry instanceof FileLayerSpec) {\n        FileEntriesLayer.Builder layerBuiler = FileEntriesLayer.builder();\n\n        FileLayerSpec fileLayer = (FileLayerSpec) entry;\n        layerBuiler.setName(fileLayer.getName());\n        // layer properties\n        fileLayer.getProperties().ifPresent(filePropertiesStack::push);\n        for (CopySpec copySpec : ((FileLayerSpec) entry).getFiles()) {\n          // copy spec properties\n          copySpec.getProperties().ifPresent(filePropertiesStack::push);\n\n          // relativize all paths to the buildRoot location\n          Path rawSrc = copySpec.getSrc();\n          Path src = rawSrc.isAbsolute() ? rawSrc : buildRoot.resolve(rawSrc);\n          AbsoluteUnixPath dest = copySpec.getDest();\n\n          if (!Files.isDirectory(src) && !Files.isRegularFile(src)) {\n            throw new UnsupportedOperationException(\n                \"Cannot create FileLayers from non-file, non-directory: \" + src.toString());\n          }\n          if (Files.isRegularFile(src)) { // regular file\n            if (!copySpec.getExcludes().isEmpty() || !copySpec.getIncludes().isEmpty()) {\n              throw new UnsupportedOperationException(\n                  \"Cannot apply includes/excludes on single file copy directives.\");\n            }\n            layerBuiler.addEntry(\n                src,\n                copySpec.isDestEndsWithSlash() ? dest.resolve(src.getFileName()) : dest,\n                filePropertiesStack.getFilePermissions(),\n                filePropertiesStack.getModificationTime(),\n                filePropertiesStack.getOwnership());\n          } else if (Files.isDirectory(src)) { // directory\n            List<PathMatcher> excludes =\n                copySpec.getExcludes().stream()\n                    .map(Layers::toPathMatcher)\n                    .collect(Collectors.toList());","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/Layers.java#L64-L100","documentation":"When converting FileLayerSpec copy directives into layer entries, Layers.toLayers resolves each src (relative to buildRoot) and requires it to be either a directory or a regular file. If Files.isDirectory and Files.isRegularFile both fail (missing path, broken symlink, special file), it throws UnsupportedOperationException naming the src.","triggerScenarios":"A copy spec's src path does not exist relative to the build root, points to a broken symlink, or is a special file (socket, device, fifo).","commonSituations":"Typos in src paths, running the CLI from the wrong working directory so relative srcs don't resolve, artifacts not yet built, dangling symlinks in the source tree.","solutions":["Verify the src path exists relative to the build root (or make it absolute).","Run the build step that produces the file/directory before Jib.","Fix or remove dangling symlinks in the copied tree.","Check that the build root (-Djib.alwaysCacheWorkDir / build context dir) is the directory you expect."],"exampleFix":"// before\n{\"name\": \"app\", \"files\": [{\"src\": \"target/app.jar\", \"dest\": \"/app\"}]} // jar not built\n// after\nmvn package && jib ...  // ensure target/app.jar exists first","handlingStrategy":"validation","validationCode":"Path src = buildRoot.resolve(copySpec.getSrc());\nif (!Files.isDirectory(src) && !Files.isRegularFile(src)) {\n  throw new IllegalStateException(\"Copy src does not exist: \" + src);\n}","typeGuard":null,"tryCatchPattern":"try {\n  jibBuild();\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().startsWith(\"Cannot create FileLayers from non-file, non-directory\")) {\n    log.error(\"Check src paths in build file relative to build root: {}\", e.getMessage());\n  } else throw e;\n}","preventionTips":["Verify all copy src paths exist before running Jib","Run artifact-producing build steps first","Run Jib from the expected working directory","Clean dangling symlinks from the source tree"],"tags":["filesystem","buildfile","path"],"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-14T05:17:10.506Z"}