{"record":{"id":"3df23c2563d78910","repo":"apple/pkl","slug":"securitymanagerexception-packageloaderror-message","errorCode":null,"errorMessage":"SecurityManagerException/PackageLoadError (message from wrapped cause)","messagePattern":"SecurityManagerException/PackageLoadError \\(message from wrapped cause\\)","errorType":"exception","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/runtime/VmImportAnalyzer.java","lineNumber":149,"sourceCode":"      } 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())\n            .withCause(e)\n            .build();\n      } catch (ExternalReaderProcessException e) {\n        throw new VmExceptionBuilder()\n            .withSourceSection(entry.sourceSection())\n            .evalError(\"externalReaderFailure\")\n            .withCause(e)\n            .build();\n      }\n    }\n    return result;\n  }\n\n  private record ImportEntry(URI moduleUri, ResolvedModuleKey resolvedModuleKey) {\n    private Import toImport() {\n      return new Import(resolvedModuleKey.getOriginal().getUri());\n    }","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/runtime/VmImportAnalyzer.java#L131-L167","documentation":"An import failed due to a security or package problem: SecurityManagerException (e.g. module URI not trusted by the security manager) or PackageLoadError (dependency package could not be loaded). The original cause is attached; there is no separate message code — the cause's message is shown.","triggerScenarios":"Importing modules from URIs the SecurityManager does not allow (not in trusted paths / no module path declared), or importing from a package that fails to load (unresolvable dependency, bad checksum, missing package) during collectImports.","commonSituations":"Running pkl in restricted mode without whitelisting file/http paths; a project dependency not listed in PklProject dependencies; corrupted or unreachable package cache.","solutions":["Read the wrapped cause message for the precise denial or package error","Allow the module's URI scheme/path in the security manager (module path / trusted roots) when intentional","Fix the project dependencies: declare the required package in PklProject and run pkl project resolve","Verify network access and package cache integrity"],"exampleFix":"// before (CLI)\npkl script.pkl\n// after (allow the path or resolve deps)\npkl --allowed-modules file,https script.pkl\n# and: pkl project resolve","handlingStrategy":"try-catch","validationCode":"if (!allowedSchemes.includes(new URL(uri).protocol)) throw new Error('module URI not trusted: ' + uri)","typeGuard":null,"tryCatchPattern":"try { evaluate(module) } catch (e) { const cause = e.cause; if (cause && (cause.name === 'SecurityManagerException' || cause.name === 'PackageLoadError')) { console.error('import blocked/package error:', cause.message) } throw e }","preventionTips":["Declare all package dependencies in PklProject and run pkl project resolve","Allow required URI schemes/paths via --allowed-modules or the security manager config","Keep the package cache healthy and verify network access to repositories"],"tags":["pkl","security","package","import"],"backgroundTag":"permission-denied","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}