{"record":{"id":"f9e6a75a9b24731a","repo":"apple/pkl","slug":"cannotloadprojectdepsjson","errorCode":"cannotLoadProjectDepsJson","errorMessage":"cannotLoadProjectDepsJson","messagePattern":"cannotLoadProjectDepsJson","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/module/ProjectDependenciesManager.java","lineNumber":254,"sourceCode":"  public URI getProjectDepsFileUri() {\n    return IoUtils.resolve(projectBaseUri, PKL_PROJECT_DEPS_FILENAME);\n  }\n\n  public URI getProjectFileUri() {\n    return declaredDependencies.projectFileUri();\n  }\n\n  private ProjectDeps getProjectDeps() {\n    synchronized (lock) {\n      if (projectDeps == null) {\n        var depsUri = getProjectDepsFileUri();\n        var moduleKey = moduleResolver.resolve(depsUri);\n        try {\n          // treat PklProject.deps.json as a module read, rather than introduce a new API.\n          var depsJson = moduleKey.resolve(securityManager).loadSource();\n          projectDeps = ProjectDeps.parse(depsJson);\n        } catch (IOException e) {\n          throw new VmExceptionBuilder()\n              .evalError(\"cannotLoadProjectDepsJson\", depsUri)\n              .withCause(e)\n              .withHint(e.getMessage() != null ? e.getMessage() : (\"Encountered error: \" + e))\n              .build();\n        } catch (JsonParseException e) {\n          throw new VmExceptionBuilder()\n              .evalError(\"invalidProjectDepsJson\", depsUri, e.getMessage())\n              .build();\n        } catch (SecurityManagerException e) {\n          throw PklBugException.unreachableCode();\n        }\n      }\n      return projectDeps;\n    }\n  }\n}\n","sourceCodeStart":236,"sourceCodeEnd":271,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/module/ProjectDependenciesManager.java#L236-L271","documentation":"cannotLoadProjectDepsJson is thrown by ProjectDependenciesManager.getProjectDeps (projectDeps, resolvedDep, dep builtins) when the PklProject.deps.json file referenced by the project cannot be read or parsed as a source. It wraps the underlying IOException as the cause and surfaces the exception's message as a hint. It means the dependency lockfile exists at the deps URI but loading its bytes failed (I/O error, not a JSON syntax problem — that's invalidProjectDepsJson).","triggerScenarios":"Calling projectDeps, resolvedDep, or dep from Pkl code when moduleKey.resolve(securityManager).loadSource() on the PklProject.deps.json URI throws IOException — e.g. file deleted after resolution, permissions denied, or path is a directory.","commonSituations":"Running pkl commands in a project where PklProject.deps.json was removed or locked by another process (e.g. during `pkl project` resolution), stale read-only checkouts, CI caches where the deps file is a directory stub, or network-backed filesystems dropping the file mid-read.","solutions":["Regenerate the deps file with `pkl project resolve` in the project root.","Check the hint/cause message for the exact I/O failure and fix that (permissions, missing file, path points at a directory).","Verify PklProject.deps.json exists and is a readable regular file next to PklProject.pkl.","Re-clone or restore the project directory from source control if the checkout is stale or corrupted."],"exampleFix":"// before: deps file missing/stale\n$ pkl eval mypkg/....pkl  # cannotLoadProjectDepsJson: file:///.../PklProject.deps.json\n// after\n$ pkl project resolve\n$ pkl eval mypkg/....pkl","handlingStrategy":"validation","validationCode":"import java.nio.file.*;\nPath deps = Path.of(projectDir).resolve(\"PklProject.deps.json\");\nif (!Files.isRegularFile(deps)) throw new IllegalStateException(\"Missing/unreadable \" + deps + \"; run `pkl project resolve`\");\nif (!Files.isReadable(deps)) throw new IllegalStateException(\"No read permission on \" + deps);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run `pkl project resolve` after cloning or updating a project before evaluating its modules.","Never hand-delete or hand-edit PklProject.deps.json.","Include PklProject.deps.json in CI cache keys so it is regenerated on mismatch.","Check file permissions in packaged/CI environments."],"tags":["io","project-deps","lockfile","pkl"],"backgroundTag":"file-read-failed","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"}