{"record":{"id":"0c61fab6775f99e2","repo":"can1357/oh-my-pi","slug":"could-not-install-omp-configuration-writeconfig","errorCode":null,"errorMessage":"Could not install omp configuration: ${writeConfig.stderr.trim()}","messagePattern":"Could not install omp configuration: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/metaharness/src/tb/agent.ts","lineNumber":124,"sourceCode":"\t\tmodelLines.push(`    baseUrl: ${gateway.url}`);\n\t\tmodelLines.push(\"    auth: oauth\");\n\t\tmodelLines.push(\"    transport: pi-native\");\n\t\tmodelLines.push(`    apiKey: ${gateway.token}`);\n\t}\n\tconst modelsYaml = `${modelLines.join(\"\\n\")}\\n`;\n\tconst configYaml = `providers:\n  openrouterVariant: ${gateway.openrouterVariant}\nmodelRoles:\n  vision: openrouter/qwen/qwen3.7-flash\nedit:\n  mode: replace\nweb_search:\n  enabled: false\n`;\n\tconst writeConfig = await vm.exec(\n\t\t`mkdir -p \"$HOME/.omp/agent\"\\ncat > \"$HOME/.omp/agent/models.yml\" <<'OMP_MODELS_EOF'\\n${modelsYaml}OMP_MODELS_EOF\\ncat > \"$HOME/.omp/agent/config.yml\" <<'OMP_CONFIG_EOF'\\n${configYaml}OMP_CONFIG_EOF`,\n\t);\n\tif (writeConfig.exitCode !== 0) throw new Error(`Could not install omp configuration: ${writeConfig.stderr.trim()}`);\n\treturn entrypoint;\n}\n","sourceCodeStart":106,"sourceCodeEnd":127,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/metaharness/src/tb/agent.ts#L106-L127","documentation":"installAgent writes models.yml and config.yml into the guest's ~/.omp/agent via a heredoc shell script. If the composite command exits non-zero, this error is thrown with the shell's stderr.","triggerScenarios":"The multi-line `mkdir -p ... cat > ... <<'EOF'` script fails — HOME unset or unwritable in the guest shell, disk full, heredoc mangled by the exec transport (quoting/newline handling), or `$HOME` expansion breaking under a non-login shell.","commonSituations":"Guest runs commands via sh -c where $HOME is not set (e.g. non-root exec user); YAML content contains a line matching the OMP_EOF delimiters (unlikely with unique delimiters); exec transport strips trailing newlines so the heredoc terminator is never seen and cat hangs or fails.","solutions":["Read stderr for the failing sub-command (mkdir vs cat)","Verify $HOME is set for the guest exec user (`vm.exec('echo $HOME')`)","Check guest disk space and that ~/.omp/agent's parent is writable","Ensure the exec transport preserves newlines verbatim in the command string","Write configs via vm.copyTo of temp files instead of heredocs if transport mangles them"],"exampleFix":"// before: heredoc through exec transport\nconst writeConfig = await vm.exec(`cat > \"$HOME/.omp/agent/models.yml\" <<'OMP_MODELS_EOF'\\n${modelsYaml}OMP_MODELS_EOF`);\n// after: stage locally and copy\nclass Tmp { }\nawait vm.copyTo(modelsYamlPath, \"/tmp/models.yml\");\nawait vm.exec(\"mkdir -p $HOME/.omp/agent && mv /tmp/models.yml $HOME/.omp/agent/models.yml\");","handlingStrategy":"fallback","validationCode":"const home = (await vm.exec('echo -n \"$HOME\"')).stdout.trim();\nif (!home) throw new Error(\"guest exec user has no $HOME\");","typeGuard":null,"tryCatchPattern":"try {\n  await installAgent(vm, binaries, gateway);\n} catch (err) {\n  if (String(err.message).includes(\"Could not install omp configuration\")) {\n    // fall back to vm.copyTo of staged config files\n  }\n  throw err;\n}","preventionTips":["Prefer vm.copyTo over heredocs for multi-line config","Ensure the exec user's $HOME exists and is writable","Keep heredoc delimiters unique and newline-safe"],"tags":["vm","configuration","shell","heredoc"],"backgroundTag":"shell-command-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}