{"record":{"id":"2b0233666093f263","repo":"apple/pkl","slug":"is-a-directory","errorCode":null,"errorMessage":"Is a directory","messagePattern":"Is a directory","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/module/ResolvedModuleKeys.java","lineNumber":111,"sourceCode":"    @Override\n    public URI getUri() {\n      return uri;\n    }\n\n    @Override\n    public String loadSource() throws IOException {\n      try {\n        if (nofollow) {\n          try (var in = Files.newInputStream(path, LinkOption.NOFOLLOW_LINKS)) {\n            return new String(in.readAllBytes(), StandardCharsets.UTF_8);\n          }\n        }\n        return Files.readString(path, StandardCharsets.UTF_8);\n      } catch (AccessDeniedException e) {\n        // Windows throws `AccessDeniedException` when reading directories.\n        // Sync error between different OSes.\n        if (Files.isDirectory(path)) {\n          throw new IOException(\"Is a directory\");\n        }\n        throw e;\n      }\n    }\n  }\n\n  private static class Url implements ResolvedModuleKey {\n    final ModuleKey original;\n    final URI uri;\n    final URL url;\n\n    Url(ModuleKey original, URI uri, URL url) {\n      this.original = original;\n      this.uri = uri;\n      this.url = url;\n    }\n\n    @Override","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/module/ResolvedModuleKeys.java#L93-L129","documentation":"The message 'Is a directory' is produced by ResolvedModuleKeys.loadSource (LocalPathModuleKey) when reading a module resolves to a directory rather than a file. On Windows, reading a directory throws AccessDeniedException, so the code checks Files.isDirectory(path) and rethrows a uniform IOException('Is a directory') to sync the error message across operating systems. This indicates a module URI/path pointed at a directory instead of a file.","triggerScenarios":"Calling loadSource on a local-path module key whose path is a directory — e.g. an import pointing at a folder (`import \"file:///some/dir\"`) or ProjectDepsManager loading a deps URI that resolves to a directory.","commonSituations":"Typing an import path without the filename (expecting index.pkl resolution that isn't supported); a path truncated mid-edit; symlinked or mount-point directories mistaken for files; a deps file placeholder directory in CI.","solutions":["Point the import/path at the actual .pkl file, e.g. `import \"dir/module.pkl\"` instead of `import \"dir\"`.","Verify with `ls`/`Get-Item` that the resolved path is a regular file, not a directory.","If a symlink is involved, retarget it to a file.","Fix any tooling or templating that generated the truncated path."],"exampleFix":"// before\nimport \"file:///home/me/project/shared\"\n// after\nimport \"file:///home/me/project/shared/config.pkl\"","handlingStrategy":"validation","validationCode":"import java.nio.file.*;\nPath p = Path.of(\"/home/me/project/shared\");\nif (!Files.isRegularFile(p)) throw new IllegalArgumentException(\"Module path must be a file, got: \" + (Files.isDirectory(p) ? \"directory\" : p));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always point imports at an explicit .pkl file, not a directory.","Verify generated paths end with a filename before passing them to the module loader.","Be aware error text is OS-synced: 'Is a directory' also appears on Windows for directory paths.","Check symlinks resolve to regular files."],"tags":["filesystem","module-loading","path","pkl"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}