{"record":{"id":"52b32c724bc8f038","repo":"apple/pkl","slug":"rethrown-packageloaderror-securitymanagerexcepti","errorCode":null,"errorMessage":"rethrown PackageLoadError / SecurityManagerException (message from cause)","messagePattern":"rethrown PackageLoadError / SecurityManagerException \\(message from cause\\)","errorType":"exception","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java","lineNumber":3263,"sourceCode":"      if (path != null && path.contains(\"\\\\\")) {\n        exceptionBuilder.withHint(\n            \"To resolve modules in nested directories, use `/` as the directory separator.\");\n      }\n      throw exceptionBuilder.build();\n    } catch (URISyntaxException e) {\n      throw exceptionBuilder()\n          .evalError(\"invalidModuleUri\", importUri)\n          .withHint(e.getReason())\n          .withSourceSection(createSourceSection(ctx))\n          .build();\n    } catch (IOException e) {\n      throw exceptionBuilder()\n          .evalError(\"ioErrorLoadingModule\", importUri)\n          .withCause(e)\n          .withSourceSection(createSourceSection(ctx))\n          .build();\n    } catch (SecurityManagerException | PackageLoadError e) {\n      throw exceptionBuilder().withSourceSection(createSourceSection(ctx)).withCause(e).build();\n    } catch (VmException e) {\n      throw exceptionBuilder()\n          .evalError(e.getMessage(), e.getMessageArguments())\n          .withCause(e.getCause())\n          .withHintBuilder(e.getHintBuilder())\n          .withSourceSection(createSourceSection(ctx))\n          .build();\n    } catch (ExternalReaderProcessException e) {\n      throw exceptionBuilder()\n          .evalError(\"externalReaderFailure\")\n          .withCause(e.getCause())\n          .withSourceSection(createSourceSection(ctx))\n          .build();\n    }\n\n    if (!resolvedUri.isAbsolute()) {\n      throw exceptionBuilder()\n          .evalError(\"cannotHaveRelativeImport\", moduleKey.getUri())","sourceCodeStart":3245,"sourceCodeEnd":3281,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java#L3245-L3281","documentation":"A `SecurityManagerException` or `PackageLoadError` raised while resolving an import is rethrown as a PklError carrying the original exception as its cause. The visible message comes from the cause (e.g. a security-manager denial of a file path, or a package/dependency resolution failure).","triggerScenarios":"Importing a module located outside the paths allowed by the security manager, or an import resolved through a package that failed to load (missing dependency, bad PackageAsset load).","commonSituations":"CLI sandboxing/`--allowed-modules` restrictions excluding the import target; cache or dependency problems with `pkl project` packages.","solutions":["Read the cause message to see whether it is a security-manager denial or a package load failure","Widen allowed modules/roots (e.g. --allowed-modules) if the path is legitimately needed","Resolve project dependencies with `pkl project resolve` and verify package coordinates","Fix the import to point inside the permitted area"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// confirm the import target is within allowed roots before eval:\n// pkl eval module.pkl --allowed-modules '**' (dev only) to see if the error disappears","typeGuard":null,"tryCatchPattern":"// Inspect the cause: if SecurityManagerException -> adjust --allowed-modules; if PackageLoadError -> run `pkl project resolve` and fix package deps","preventionTips":["Keep all imports inside directories allowed by the security manager","Resolve project dependencies before evaluation","Document required --allowed-modules settings for your project"],"tags":["pkl","import","security-manager","package-load"],"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"}