{"record":{"id":"4df6a17a8802e20d","repo":"apple/pkl","slug":"cannotfindstdlibmodule","errorCode":"cannotFindStdLibModule","errorMessage":"cannotFindStdLibModule","messagePattern":"cannotFindStdLibModule","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/runtime/ModuleCache.java","lineNumber":125,"sourceCode":"        case \"ref\":\n          return RefModule.getModule();\n        case \"reflect\":\n          return ReflectModule.getModule();\n        case \"release\":\n          return ReleaseModule.getModule();\n        case \"semver\":\n          return SemVerModule.getModule();\n        case \"settings\":\n          // always needed if ~/.config/pkl/settings.pkl is present\n          return SettingsModule.getModule();\n        case \"test\":\n          return TestModule.getModule();\n        case \"xml\":\n          return XmlModule.getModule();\n        default:\n          if (!STDLIB_MODULE_URIS.contains(moduleKey.getUri())) {\n            var stdlibModules = String.join(\"\\n\", Release.current().standardLibrary().modules());\n            throw new VmExceptionBuilder()\n                .withOptionalLocation(importNode)\n                .evalError(\"cannotFindStdLibModule\", moduleName, stdlibModules)\n                .build();\n          }\n      }\n    }\n\n    if (!moduleKey.isCached()) {\n      var resolvedKey = resolve(moduleKey, securityManager, importNode);\n      return doLoad(\n          moduleKey,\n          resolvedKey,\n          moduleResolver,\n          moduleInstantiator,\n          moduleInitializer,\n          importNode);\n    }\n","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/runtime/ModuleCache.java#L107-L143","documentation":"ModuleCache.getOrLoad throws cannotFindStdLibModule when a `pkl:`-scheme stdlib import names a module that does not exist in the current Pkl release's standard library. The error lists all valid standard library module URIs to help pick the right name. It only fires after the switch over known module names falls through and the URI is not in STDLIB_MODULE_URIS.","triggerScenarios":"An import like `import \"pkl:math2\"` (misspelled stdlib module) resolved as a stdlib module key but absent from Release.current().standardLibrary().modules().","commonSituations":"Typos in `pkl:` imports; using a stdlib module that was renamed or removed between Pkl versions; importing a hypothetical module from documentation of a newer Pkl than installed.","solutions":["Compare your import against the module list printed in the error and fix the module name (e.g. `pkl:math`, `pkl:base`).","Check the stdlib docs for your installed Pkl version; the module may not exist yet in your release.","Upgrade Pkl if the module exists only in newer releases."],"exampleFix":"// before\nimport \"pkl:maths\" as maths\n// after\nimport \"pkl:math\" as maths","handlingStrategy":"validation","validationCode":"val stdlib = setOf(\"base\",\"math\",\"test\",\"xml\",\"platform\",\"json\",\"yaml\",\"toml\",\"pkl\",\"reflect\",\"internal\")\nfun isStdlibImport(uri: String) = uri.startsWith(\"pkl:\") && uri.removePrefix(\"pkl:\").split(\"/\").first() in stdlib","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Autocomplete stdlib imports from the versioned docs","Lint imports against Release.current().standardLibrary().modules()","After a Pkl upgrade, re-check any imports of renamed modules"],"tags":["pkl","stdlib","import","module-not-found"],"backgroundTag":"resource-not-found","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"}