{"record":{"id":"f7430adefd37a380","repo":"apple/pkl","slug":"directory-dir-does-not-contain-a-pklproject-file","errorCode":null,"errorMessage":"Directory $dir does not contain a PklProject file.","messagePattern":"Directory \\$dir does not contain a PklProject file\\.","errorType":"exception","errorClass":"CliException","httpStatus":null,"severity":"error","filePath":"pkl-cli/src/main/kotlin/org/pkl/cli/CliProjectCommand.kt","lineNumber":41,"sourceCode":"import org.pkl.commons.cli.CliException\nimport org.pkl.core.module.ProjectDependenciesManager.PKL_PROJECT_FILENAME\n\nabstract class CliProjectCommand(cliOptions: CliBaseOptions, private val projectDirs: List<Path>) :\n  CliCommand(cliOptions) {\n\n  protected val normalizedProjectFiles: List<Path> by lazy {\n    if (projectDirs.isEmpty()) {\n      val projectFile =\n        cliOptions.normalizedWorkingDir.getProjectFile(cliOptions.normalizedRootDir)\n          ?: throw CliException(\n            \"No project visible to the working directory. Ensure there is a PklProject file in the workspace, or provide an explicit project directory as an argument.\"\n          )\n      return@lazy listOf(projectFile.normalize())\n    }\n    projectDirs.map(cliOptions.normalizedWorkingDir::resolve).map { dir ->\n      val projectFile = dir.resolve(PKL_PROJECT_FILENAME)\n      if (!Files.exists(projectFile)) {\n        throw CliException(\"Directory $dir does not contain a PklProject file.\")\n      }\n      projectFile.normalize()\n    }\n  }\n}\n","sourceCodeStart":23,"sourceCodeEnd":47,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-cli/src/main/kotlin/org/pkl/cli/CliProjectCommand.kt#L23-L47","documentation":"This error is thrown by the `pkl project` command when one of the directories given on the command line (or the working directory) does not contain a file named PklProject. The command requires each target directory to be a Pkl project root, so before doing any work it resolves PKL_PROJECT_FILENAME in each directory and aborts with a CliException if the file does not exist. It is a precondition check on the user-supplied directory inputs.","triggerScenarios":"Running `pkl project <dir>` (or relying on the normalized working directory) where <dir> exists but contains no PklProject file; typos in the path passed with --project-dir style options; running the command from a directory that only contains sub-projects.","commonSituations":"Running `pkl project` in a repo root that only has PklProject files in subdirectories; misspelling the project directory; assuming a plain directory of .pkl files is a project; renaming or deleting the PklProject file during refactoring.","solutions":["Verify the directory contains a file named exactly PklProject (case-sensitive) with `ls <dir>/PklProject`","Pass the directory that actually contains the PklProject file, not its parent or a sibling","Run `pkl project init <dir>` to create a new PklProject file if the directory should be a project","Check the current working directory if no explicit directory was given; the command resolves relative dirs against it"],"exampleFix":"// before\npkl project ./mypkg/src\n// after\npkl project ./mypkg  # directory containing PklProject","handlingStrategy":"validation","validationCode":"if not (dir / \"PklProject\").exists(): raise SystemExit(f\"{dir} lacks PklProject; run `pkl project init {dir}`\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify PklProject exists before invoking any `pkl project` subcommand","Note PklProject (no extension, exact case) is required","Point commands at the project root, not subdirectories"],"tags":["cli","pkl","missing-file","project"],"backgroundTag":"file-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"}