{"record":{"id":"b9ead56b29506cc1","repo":"apple/pkl","slug":"failed-to-write-to-depsfile-e-message","errorCode":null,"errorMessage":"Failed to write to $depsFile: ${e.message}","messagePattern":"Failed to write to \\$depsFile: (.+?)","errorType":"exception","errorClass":"PklException","httpStatus":null,"severity":"error","filePath":"pkl-cli/src/main/kotlin/org/pkl/cli/CliProjectResolver.kt","lineNumber":56,"sourceCode":"        PackageResolver.getInstance(\n          SecurityManagers.standard(\n            allowedModules,\n            allowedResources,\n            SecurityManagers.defaultTrustLevels,\n            rootDir,\n          ),\n          httpClient,\n          moduleCacheDir,\n        )\n      val dependencies = ProjectDependenciesResolver(project, packageResolver, errWriter).resolve()\n      val depsFile =\n        projectFile.parent.resolve(ProjectDependenciesManager.PKL_PROJECT_DEPS_FILENAME).toFile()\n      try {\n        depsFile.outputStream().use { dependencies.writeTo(it) }\n        consoleWriter.appendLine(depsFile.toString())\n        consoleWriter.flush()\n      } catch (e: IOException) {\n        throw PklException(\"Failed to write to $depsFile: ${e.message}\", e)\n      }\n    }\n  }\n}\n","sourceCodeStart":38,"sourceCodeEnd":61,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-cli/src/main/kotlin/org/pkl/cli/CliProjectResolver.kt#L38-L61","documentation":"Thrown by CliProjectResolver.doRun when writing the generated PklProjectDependencies file (PklProjectDependencies.pem deps file next to the PklProject) fails with an IOException. `pkl project resolve` computes the dependency graph and persists it to disk; if the file cannot be opened or written, the resolver wraps the IOException in a PklException with this message, which includes the deps file path and the underlying IOException message.","triggerScenarios":"Running `pkl project resolve` when the target deps file cannot be written: read-only filesystem or directory, missing write permissions, the path is a directory instead of a file, or disk full.","commonSituations":"Running inside a read-only container or CI workspace; file owned by another user after running as root earlier; the project directory was made immutable; NFS/permissions issues in shared dev environments.","solutions":["Check and fix write permissions on the project directory and any existing PklProjectDependencies file (e.g. chmod/chown)","Remove the stale deps file if it is owned by another user or immutable","Ensure the filesystem is writable (not mounted read-only) and has free disk space","Re-run `pkl project resolve`"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { resolveProject() } catch (PklException e) { if (e.getMessage().startsWith(\"Failed to write to\")) handleUnwritableDepsFile(); else throw e; }","preventionTips":["Ensure the project dir is writable before running resolve","Don't run as root in shared checkouts; fix ownership of generated deps files"],"tags":["cli","pkl","io","file-write","filesystem"],"backgroundTag":"file-write-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"}