can1357/oh-my-pi · error · Error

--alias requires --profile <name> or OMP_PROFILE

Error message

--alias requires --profile <name> or OMP_PROFILE

What it means

Argument-validation error thrown by runCli: the user passed --alias to install a command alias, but no profile was specified either via --profile on the same invocation or via the OMP_PROFILE (or legacy PI_PROFILE) environment variable. Aliases are namespaced per profile, so the CLI refuses to guess which profile the alias belongs to.

Source

Thrown at packages/coding-agent/src/cli.ts:364

		const extracted = extractProfileFlags(resolvedArgv);
		resolvedArgv = extracted.argv;
		if (extracted.profile !== undefined) {
			setProfile(extracted.profile);
		} else {
			// No explicit --profile: activate any OMP_PROFILE/PI_PROFILE inherited
			// from the environment. Module-load resolution deliberately swallows an
			// invalid value to avoid an uncaught throw before this try/catch is in
			// scope (see `readProfileFromEnvSafe` in dirs.ts), and callers may set
			// OMP_PROFILE after importing this module (profile aliases/tests). Surfacing
			// validation here turns `OMP_PROFILE=.. omp --version` into a clean error;
			// calling setProfile keeps every later path helper on the env-selected
			// profile instead of the default agent directory.
			setProfile(resolveProfileEnv(process.env.OMP_PROFILE, process.env.PI_PROFILE));
		}
		if (extracted.aliasName !== undefined) {
			const profile = extracted.profile ?? getActiveProfile();
			if (!profile) {
				throw new Error("--alias requires --profile <name> or OMP_PROFILE");
			}
			const result = await installProfileAlias({
				profile,
				aliasName: extracted.aliasName,
				command: resolveProfileAliasCommandFromProcess(),
			});
			process.stdout.write(
				`Created ${result.aliasName} for profile ${result.profile} in ${result.configPath}\n` +
					`Restart your shell or run: ${result.reloadedWith}\n` +
					`Then use: ${result.aliasName} update, ${result.aliasName} --version, or ${result.aliasName}\n`,
			);
			return;
		}
	} catch (error) {
		const message = error instanceof Error ? error.message : String(error);
		process.stderr.write(`Error: ${message}\n`);
		process.exitCode = 1;
		return;

View on GitHub (pinned to 9690622007)

Solutions

  1. Add --profile <name> to the same command as --alias
  2. Set the OMP_PROFILE environment variable (or legacy PI_PROFILE) to the target profile
  3. Verify getActiveProfile/resolveProfileEnv are receiving the env var (check shell/export context in scripts)
  4. If scripting, pass both flags explicitly: `omp --profile work --alias myalias`

Example fix

// before (fails)
omp --alias deploy
// after
omp --profile work --alias deploy
// or
export OMP_PROFILE=work
omp --alias deploy
Defensive patterns

Strategy: validation

Validate before calling

function canInstallAlias(args: { alias?: string; profile?: string }, env: NodeJS.ProcessEnv): boolean {
	return !args.alias || Boolean(args.profile || env.OMP_PROFILE || env.PI_PROFILE);
}

Type guard

function aliasInvocationHasProfile(args: { aliasName?: string; profile?: string }, env: NodeJS.ProcessEnv): boolean {
	return args.aliasName === undefined || (args.profile !== undefined || Boolean(env.OMP_PROFILE ?? env.PI_PROFILE));
}

Try / catch

try {
	await runCli(argv);
} catch (err) {
	if (err.message.includes("--alias requires --profile")) {
		console.error("Usage: omp --profile <name> --alias <alias> (or set OMP_PROFILE)");
		process.exitCode = 1;
	} else throw err;
}

Prevention

When it happens

Trigger: Invoking the CLI with `--alias <name>` while `extracted.profile` is undefined and getActiveProfile() returns null — i.e. neither --profile <name> nor OMP_PROFILE/PI_PROFILE was set for this invocation.

Common situations: Scripting alias setup in CI without setting OMP_PROFILE; forgetting that --profile must accompany --alias on the same command line; relying on a profile that was never set as active in the environment.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/16a5b2c3c7b6848f. Report an issue: GitHub.