can1357/oh-my-pi · error · Error

--environment must be docker|apple-container

Error message

--environment must be docker|apple-container

What it means

parseArgs validates --environment against the two supported harness execution environments: docker and apple-container (Docker Desktop vs Apple's container runtime/vmnet). Any other value is rejected because environment-specific setup (networking, gateway URLs, compose files) branches on exactly these two.

Source

Thrown at packages/metaharness/src/runner.ts:356

				process.stdout.write(HELP);
				process.exit(0);
				break;
			case "-e":
			case "--env": {
				const spec = take(arg);
				const eq2 = spec.indexOf("=");
				if (eq2 === -1) {
					const hostVal = process.env[spec];
					if (hostVal !== undefined) cfg.env[spec] = hostVal;
				} else {
					cfg.env[spec.slice(0, eq2)] = spec.slice(eq2 + 1);
				}
				break;
			}
			case "--environment": {
				const v = take(arg);
				if (v !== "docker" && v !== "apple-container") {
					throw new Error("--environment must be docker|apple-container");
				}
				cfg.envType = v;
				break;
			}
			default:
				throw new Error(`unknown flag: ${arg} (see --help)`);
		}
	}
	if (cfg.models.length === 0) cfg.models = ["anthropic/claude-sonnet-4-6"];
	if (cfg.envType === "apple-container") {
		if (cfg.hostNetwork) throw new Error("--host-network is docker-only (compose overlay)");
		// host.docker.internal doesn't exist on vmnet; containers reach the host at the bridge address.
		if (cfg.gatewayUrl === DOCKER_GATEWAY_URL) cfg.gatewayUrl = VMNET_GATEWAY_URL;
	}
	return cfg;
}

// ─────────────────────────────────────────────────────────────────── resume

View on GitHub (pinned to 9690622007)

Solutions

  1. Use exactly `docker` or `apple-container` (lowercase).
  2. On macOS wanting Apple's container runtime use `--environment apple-container`; otherwise use `--environment docker`.
  3. Check `runner --help` for the current accepted values.
  4. If you need a new environment type, it requires a code change — the check is a hardcoded string comparison.

Example fix

// before
runner --environment Docker
// after
runner --environment docker
Defensive patterns

Strategy: validation

Validate before calling

const ENV_TYPES = ["docker","apple-container"];
if (environment !== undefined && !ENV_TYPES.includes(environment)) {
  throw new Error(`--environment must be docker|apple-container, got: ${environment}`);
}

Type guard

function isEnvType(v: unknown): v is "docker"|"apple-container" {
  return v === "docker" || v === "apple-container";
}

Try / catch

try {
  await runHarness({ environment });
} catch (e) {
  if (e instanceof Error && e.message.includes("--environment must be")) {
    console.error(`Unsupported environment '${environment}'. Use docker or apple-container.`);
  } else throw e;
}

Prevention

When it happens

Trigger: `runner --environment podman`, `--environment container`, `--environment Docker` (capitalized), or an interpolated value from CI that says something like 'kubernetes'.

Common situations: Users on Linux assuming other container runtimes are supported; scripts ported from other harnesses using different environment names; case-sensitivity typos.

Related errors


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