can1357/oh-my-pi · error · Error
Invalid alias "${aliasName}". Refusing to create a ${shell}
Error message
Invalid alias "${aliasName}". Refusing to create a ${shell} reserved word. What it means
validateAliasName rejects alias names that collide with reserved words of the target shell (e.g. `if`, `else`, `function`, PowerShell cmdlet keywords). Installing such an alias would produce a shell profile that fails to parse or silently breaks shell semantics. The reserved set is shell-specific via getReservedAliasNames(shell).
Source
Thrown at packages/coding-agent/src/cli/profile-alias.ts:161
return POSIX_RESERVED_ALIAS_NAMES;
case "fish":
return FISH_RESERVED_ALIAS_NAMES;
case "powershell":
case "pwsh":
return POWERSHELL_RESERVED_ALIAS_NAMES;
}
}
function validateAliasName(aliasName: string, shell: ProfileAliasShell): string {
const normalized = aliasName.trim();
if (!ALIAS_NAME_RE.test(normalized)) {
throw new Error(`Invalid alias "${aliasName}". Alias names must match ${ALIAS_NAME_RE.source}.`);
}
if (normalized.toLowerCase() === "omp") {
throw new Error('Invalid alias "omp". Refusing to shadow the base omp command.');
}
if (getReservedAliasNames(shell).has(normalized.toLowerCase())) {
throw new Error(`Invalid alias "${aliasName}". Refusing to create a ${shell} reserved word.`);
}
return normalized;
}
// On Windows the launching shell is rarely exported through $SHELL, so when it
// is missing we infer the PowerShell edition from the inherited environment.
// PowerShell 7 (pwsh) always seeds PSModulePath with separator-delimited
// ".../PowerShell/..." module directories (plus the Windows PowerShell ones for
// back-compat), whereas Windows PowerShell 5.1 only ever lists
// ".../WindowsPowerShell/...". The separator anchors keep "WindowsPowerShell"
// from matching. POWERSHELL_DISTRIBUTION_CHANNEL is set only by some pwsh
// distributions, so it stays a secondary hint rather than the primary signal.
function detectWindowsPowerShell(env: NodeJS.ProcessEnv): ProfileAliasShell {
const modulePath = env.PSModulePath ?? env.PSMODULEPATH ?? env.psmodulepath ?? "";
if (/[\\/]PowerShell[\\/]/i.test(modulePath)) return "pwsh";
if (env.POWERSHELL_DISTRIBUTION_CHANNEL) return "pwsh";
return "powershell";
}View on GitHub (pinned to 9690622007)
Solutions
- Pick a non-reserved alias name, e.g. append a suffix like `-cmd` (`--alias for-cmd`)
- Verify the name against your shell's reserved words before running the command
- If a script generates names, filter them against getReservedAliasNames for the target shell first
Example fix
// before omp --profile work --alias for // after omp --profile work --alias for-work
Defensive patterns
Strategy: validation
Validate before calling
import { getReservedAliasNames } from "./profile-alias"; // or replicate the check
const name = aliasName.trim();
if (getReservedAliasNames("bash").has(name.toLowerCase())) throw new Error(`"${aliasName}" is a shell reserved word`); Type guard
function isReservedWord(name: string, shell: string, reserved: Set<string>): boolean {
return reserved.has(name.trim().toLowerCase());
} Try / catch
try {
await installProfileAlias({ profile, aliasName });
} catch (err) {
if (err instanceof Error && err.message.includes('reserved word')) {
console.error(`Pick a name that is not a ${shell} reserved word.`);
return;
}
throw err;
} Prevention
- Check candidate names against your shell's keyword list (bash/zsh keywords, PowerShell cmdlet/keyword names) before installing
- Avoid one- and two-letter generic names that commonly collide (for, if, do, in)
- When generating names programmatically, append a suffix like "-cmd" to guarantee non-reserved identifiers
When it happens
Trigger: Running `omp --alias <reservedWord>` where the (lowercased) name is in getReservedAliasNames(shell) for the detected shell — e.g. `--alias for` under bash/zsh or `--alias if` under PowerShell.
Common situations: Choosing short convenient names like `for`, `do`, `in`, or `switch` that happen to be shell keywords; scripts generating aliases from user input without pre-checking.
Related errors
- Invalid alias "${aliasName}". Alias names must match ${ALIAS
- Invalid alias "omp". Refusing to shadow the base omp command
- invalid {} argument: {}
- invalid Zero increment value: {}
- --agents must be a positive integer
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/b4692abb22a098ce.
Report an issue: GitHub.