{"record":{"id":"c97b33e8aaaf9d60","repo":"multica-ai/multica","slug":"read-shared-env-w","errorCode":null,"errorMessage":"read shared .env: %w","messagePattern":"read shared \\.env: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/internal/daemon/execenv/hermes_home.go","lineNumber":458,"sourceCode":"\n// writeDerivedHermesEnv writes the task-local .env: the source home's .env\n// contents (credentials/settings preserved) with any HERMES_HOME assignment\n// removed, then a pinned HERMES_HOME pointing at the overlay appended last so it\n// wins. Hermes loads <HERMES_HOME>/.env with override=True right after profile\n// resolution, so without this an out-of-band HERMES_HOME= in the source .env\n// would relocate the home past the overlay (dropping bound skills and memory\n// isolation). We always write the file — even when the source has none — so the\n// overlay .env \"loads\" and Hermes' project-.env fallback (override=True only when\n// no user .env loaded) can't relocate the home either. Written 0600 via atomic\n// replace since it can hold API-key secrets; reuse also repairs prior perms.\nfunc writeDerivedHermesEnv(sharedHome, hermesHome string) error {\n\tdst := filepath.Join(hermesHome, \".env\")\n\n\tvar body []byte\n\tsrc, err := os.ReadFile(filepath.Join(sharedHome, \".env\"))\n\tif err != nil {\n\t\tif !os.IsNotExist(err) {\n\t\t\treturn fmt.Errorf(\"read shared .env: %w\", err)\n\t\t}\n\t} else {\n\t\tbody = stripDotenvAssignment(src, \"HERMES_HOME\")\n\t}\n\n\tvar buf strings.Builder\n\tif len(body) > 0 {\n\t\tbuf.Write(body)\n\t\tif body[len(body)-1] != '\\n' {\n\t\t\tbuf.WriteByte('\\n')\n\t\t}\n\t}\n\t// Pin HERMES_HOME to the overlay. Single-quote the value so python-dotenv\n\t// treats it literally (no escaping / var expansion) — task home paths can\n\t// contain spaces or other characters under the workspaces root.\n\tfmt.Fprintf(&buf, \"HERMES_HOME='%s'\\n\", hermesHome)\n\n\treturn writeFileAtomic(dst, []byte(buf.String()), 0o600)","sourceCodeStart":440,"sourceCodeEnd":476,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/internal/daemon/execenv/hermes_home.go#L440-L476","documentation":"Error \"read shared .env: %w\" thrown in multica-ai/multica.","triggerScenarios":"Thrown at server/internal/daemon/execenv/hermes_home.go:458 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that the shared .env file is readable."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}