{"record":{"id":"c6c00ce4d85aa367","repo":"apple/pkl","slug":"cannotfindmodule-c6c00c","errorCode":"cannotFindModule","errorMessage":"cannotFindModule","messagePattern":"cannotFindModule","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/runtime/VmImportAnalyzer.java","lineNumber":132,"sourceCode":"            var moduleUri = globElement.uri();\n            var mk = moduleResolver.resolve(moduleUri);\n            var rmk = mk.resolve(securityManager);\n            result.add(new ImportEntry(moduleUri, rmk));\n          }\n        } else {\n          var resolvedUri =\n              IoUtils.resolve(securityManager, moduleKey, IoUtils.toUri(entry.stringValue()));\n          var mKey = moduleResolver.resolve(resolvedUri);\n          var rmk = mKey.resolve(securityManager);\n          result.add(new ImportEntry(resolvedUri, rmk));\n        }\n      } catch (InvalidGlobPatternException e) {\n        throw new VmExceptionBuilder()\n            .evalError(\"invalidGlobPattern\", entry.stringValue())\n            .withSourceSection(entry.sourceSection())\n            .build();\n      } catch (FileNotFoundException | NoSuchFileException e) {\n        throw new VmExceptionBuilder()\n            .evalError(\"cannotFindModule\", entry.stringValue())\n            .withSourceSection(entry.sourceSection())\n            .build();\n      } catch (URISyntaxException e) {\n        throw new VmExceptionBuilder()\n            .evalError(\"invalidModuleUri\", entry.stringValue())\n            .withHint(e.getReason())\n            .withSourceSection(entry.sourceSection())\n            .build();\n      } catch (IOException e) {\n        throw new VmExceptionBuilder()\n            .evalError(\"ioErrorLoadingModule\", entry.stringValue())\n            .withCause(e)\n            .withSourceSection(entry.sourceSection())\n            .build();\n      } catch (SecurityManagerException | PackageLoadError e) {\n        throw new VmExceptionBuilder()\n            .withSourceSection(entry.sourceSection())","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/runtime/VmImportAnalyzer.java#L114-L150","documentation":"A module referenced by an import/glob expansion could not be found: the resolver threw FileNotFoundException/NoSuchFileException, converted to cannotFindModule with the entry's string value and source section.","triggerScenarios":"import(\"missing/file.pkl\") or a glob that resolves to paths deleted before reading; classpath/path missing during collectImports.","commonSituations":"Typo in the module path; file moved/renamed; running from a different working directory; package dependency not fetched.","solutions":["Check the path/URI spelling at the reported source section","Ensure the referenced module exists relative to the importing module or via the correct scheme (project:, package:, file:, etc.)","Fetch/sync package dependencies (pkl project resolve) if it comes from a dependency"],"exampleFix":"// before\nimport(\"confg.pkl\")\n// after\nimport(\"config.pkl\")","handlingStrategy":"validation","validationCode":"for (const dep of imports) { if (!fs.existsSync(resolve(importerDir, dep))) throw new Error('missing module: ' + dep) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify import paths relative to the importing module","Run `pkl project resolve` for package dependencies","Keep module files in place; rename with search/replace"],"tags":["pkl","import","not-found","filesystem"],"backgroundTag":"file-not-found","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}