can1357/oh-my-pi · error · Error
Found "${start}" without a matching "${end}" in the shell co
Error message
Found "${start}" without a matching "${end}" in the shell config. The managed alias block is malformed; remove the stale marker line and rerun --alias. What it means
upsertBlock found the start marker `# >>> omp profile alias: <name> >>>` in the shell config but no matching end marker `# <<< ... <<<`. The managed block is malformed, and blindly appending would corrupt the config, so the tool refuses and asks for manual cleanup. This is a data-integrity guard over hand-edited shell rc files.
Source
Thrown at packages/coding-agent/src/cli/profile-alias.ts:315
case "powershell":
case "pwsh":
body = [`function ${aliasName} {`, ` & ${command.powerShell} --profile=${profile} @args`, "}"].join("\n");
break;
default:
body = [`${aliasName}() {`, ` command ${command.posix} --profile=${profile} "$@"`, "}"].join("\n");
break;
}
return { block: `${start}\n${body}\n${end}`, command: profiledCommand };
}
function upsertBlock(content: string, aliasName: string, block: string): string {
const start = `# >>> omp profile alias: ${aliasName} >>>`;
const end = `# <<< omp profile alias: ${aliasName} <<<`;
const startIndex = content.indexOf(start);
if (startIndex !== -1) {
const endIndex = content.indexOf(end, startIndex + start.length);
if (endIndex === -1) {
throw new Error(
`Found "${start}" without a matching "${end}" in the shell config. ` +
`The managed alias block is malformed; remove the stale marker line and rerun --alias.`,
);
}
const afterEnd = endIndex + end.length;
const prefix = content.slice(0, startIndex).replace(/[\t ]*\n?$/, "");
const suffix = content.slice(afterEnd).replace(/^\n?/, "");
return [prefix, block, suffix].filter(Boolean).join("\n\n").replace(/\n*$/, "\n");
}
const trimmed = content.replace(/\s*$/, "");
return `${trimmed}${trimmed ? "\n\n" : ""}${block}\n`;
}
function readAliasConfigText(filePath: string): Promise<string> {
return Bun.file(filePath).text();
}
export async function readProfileAliasConfigFile(View on GitHub (pinned to 9690622007)
Solutions
- Open the shell config and delete the stale `# >>> omp profile alias: <name> >>>` line (and any orphaned alias lines below it)
- Rerun `omp --alias ...` so a fresh, complete block is installed
- Restore the missing `# <<< omp profile alias: <name> <<<` line if you want to keep the block and rerun instead
Example fix
// before (~/.zshrc) # >>> omp profile alias: work >>> alias work='omp --profile work' // after (delete stale marker, then rerun --alias) alias work='omp --profile work' # or remove entirely and let the installer rewrite it
Defensive patterns
Strategy: try-catch
Validate before calling
const cfg = await Bun.file(shellConfigPath).text();
const start = `# >>> omp profile alias: ${aliasName} >>>`;
const end = `# <<< omp profile alias: ${aliasName} <<<`;
if (cfg.includes(start) && cfg.indexOf(end, cfg.indexOf(start) + start.length) === -1) {
throw new Error(`Malformed omp alias block in ${shellConfigPath}; remove the stale marker first.`);
} Try / catch
try {
await installProfileAlias(options);
} catch (err) {
if (err instanceof Error && err.message.includes("without a matching")) {
// Repair: strip the orphan start marker line, then retry once
let text = await Bun.file(configPath).text();
text = text.split("\n").filter(l => !l.includes(`# >>> omp profile alias: ${aliasName} >>>`)).join("\n");
await Bun.write(configPath, text);
await installProfileAlias(options);
return;
}
throw err;
} Prevention
- Never hand-edit the marker lines `# >>> omp profile alias: ... >>>` / `<<< ... <<<` in your rc file
- Resolve merge conflicts by keeping both marker lines of the managed block, not just one
- Back up your shell config before running --alias, and re-run --alias rather than manually deleting partial blocks
When it happens
Trigger: Re-running `omp --alias` for an alias whose previously installed block in ~/.bashrc, ~/.zshrc, etc. had its end-marker line deleted or mangled by manual editing, a truncating editor, or a merge conflict that removed only the closing line.
Common situations: Hand-editing the rc file and deleting the `<<<` comment thinking it was noise; git merge conflicts resolving to keep only the block header; partial file writes/interruptions during a prior install.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- --list-details, --exec, and --exec-batch are not supported b
- positional paths cannot be combined with --search-path
- unknown file type: {value}
- invalid size: {value}
- err.to_string() (size parse error)
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/55305973f0fe83f7.
Report an issue: GitHub.