{"record":{"id":"89f015d098244d04","repo":"apple/pkl","slug":"cannot-call-both-setsecuritymanager-and-setproj","errorCode":null,"errorMessage":"Cannot call both `setSecurityManager` and `setProject`, because both define security manager settings. Call `setProjectOnly` if the security manager is desired.","messagePattern":"Cannot call both `setSecurityManager` and `setProject`, because both define security manager settings\\. Call `setProjectOnly` if the security manager is desired\\.","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/EvaluatorBuilder.java","lineNumber":493,"sourceCode":"    this.powerAssertionsEnabled = powerAssertions;\n    return this;\n  }\n\n  /** Returns whether power assertions are enabled. */\n  public boolean getPowerAssertionsEnabled() {\n    return powerAssertionsEnabled;\n  }\n\n  /**\n   * Given a project, sets its dependencies, and also applies any evaluator settings if set.\n   *\n   * @throws IllegalStateException if {@link #setSecurityManager(SecurityManager)} was also called.\n   */\n  public EvaluatorBuilder applyFromProject(Project project) {\n    this.dependencies = project.getDependencies();\n    var settings = project.getResolvedEvaluatorSettings();\n    if (securityManager != null) {\n      throw new IllegalStateException(\n          \"Cannot call both `setSecurityManager` and `setProject`, because both define security manager settings. Call `setProjectOnly` if the security manager is desired.\");\n    }\n    if (settings.allowedModules() != null) {\n      setAllowedModules(settings.allowedModules());\n    }\n    if (settings.allowedResources() != null) {\n      setAllowedResources(settings.allowedResources());\n    }\n    if (settings.externalProperties() != null) {\n      setExternalProperties(settings.externalProperties());\n    }\n    if (settings.env() != null) {\n      setEnvironmentVariables(settings.env());\n    }\n    if (settings.timeout() != null) {\n      setTimeout(settings.timeout().toJavaDuration());\n    }\n    if (settings.modulePath() != null) {","sourceCodeStart":475,"sourceCodeEnd":511,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/EvaluatorBuilder.java#L475-L511","documentation":"Thrown by EvaluatorBuilder.applyFromProject when a custom SecurityManager was already set: the project's resolved evaluator settings may themselves define security settings, and applying them would conflict with the explicitly supplied SecurityManager. The message points to setProjectOnly, which applies project dependencies/settings without touching security configuration.","triggerScenarios":"Thrown at pkl-core/src/main/java/org/pkl/core/EvaluatorBuilder.java:493 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call setProjectOnly instead of applyFromProject to keep the custom SecurityManager.","Do not call setSecurityManager when the project's evaluator settings should govern security."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}