openai/codex · error · std::io::Error

legacy `profile = "{profile}"` config is no longer supported

Error message

legacy `profile = "{profile}"` config is no longer supported; use `--profile {profile}` with `{profile}.config.toml` instead

What it means

Codex removed the top-level `profile` key from config.toml. During Config construction, any `profile = "<name>"` found in the merged ConfigToml layers (user config.toml, project .codex/config.toml, or managed layers) aborts loading with an io::Error of kind InvalidData. The message names the profile and points at the replacement: run with `--profile <name>` and keep that profile's overrides in `<name>.config.toml`.

Source

Thrown at codex-rs/core/src/config/mod.rs:3258

            return Err(std::io::Error::new(
                std::io::ErrorKind::InvalidInput,
                "`sandbox_mode` and `permission_profile` overrides cannot both be set",
            ));
        }
        if sandbox_mode.is_some() && default_permissions_override.is_some() {
            return Err(std::io::Error::new(
                std::io::ErrorKind::InvalidInput,
                "`sandbox_mode` and `default_permissions` overrides cannot both be set",
            ));
        }
        if permission_profile.is_some() && default_permissions_override.is_some() {
            return Err(std::io::Error::new(
                std::io::ErrorKind::InvalidInput,
                "`permission_profile` and `default_permissions` overrides cannot both be set",
            ));
        }
        if let Some(profile) = cfg.profile.as_deref() {
            return Err(std::io::Error::new(
                std::io::ErrorKind::InvalidData,
                format!(
                    "legacy `profile = \"{profile}\"` config is no longer supported; use `--profile {profile}` with `{profile}.config.toml` instead"
                ),
            ));
        }

        let tool_suggest = resolve_tool_suggest_config(&cfg, &config_layer_stack);
        let feature_overrides = FeatureOverrides {
            web_search_request: override_tools_web_search_request,
        };

        let configured_features = Features::from_sources(
            FeatureConfigSource {
                features: cfg.features.as_ref(),
                experimental_use_unified_exec_tool: cfg.experimental_use_unified_exec_tool,
            },
            FeatureConfigSource {

View on GitHub (pinned to 339751715c)

Solutions

  1. Delete the `profile = "..."` line from every config.toml Codex loads (~/.codex/config.toml, project .codex/config.toml, managed layers).
  2. Start Codex with the flag instead: `codex --profile work`.
  3. Move that profile's overrides into `~/.codex/work.config.toml` so `--profile work` applies them.
  4. If the error persists, another layer still defines `profile`; grep every config root again.

Example fix

# ~/.codex/config.toml - before
profile = "work"
model = "gpt-5"

# after - shared settings only
model = "gpt-5"

# ~/.codex/work.config.toml - the profile's overrides
model = "gpt-5-mini"

# launch with
codex --profile work
Defensive patterns

Strategy: validation

Validate before calling

# Pre-flight: reject configs that still carry the removed key
grep -n '^profile' ~/.codex/config.toml .codex/config.toml 2>/dev/null && echo 'remove the legacy profile key; use --profile instead'

Try / catch

match config_result {
    Err(ref e) if e.kind() == std::io::ErrorKind::InvalidData
        && e.to_string().contains("legacy `profile`") => {
        // strip the key or switch to --profile, then retry once
    }
    other => other,
}

Prevention

When it happens

Trigger: Any config load (codex TUI start, `codex exec`, app-server startup) while some loaded layer contains `profile = "work"`. The check runs early, right after the sandbox_mode / permission_profile / default_permissions mutual-exclusion checks and before features or permissions are resolved.

Common situations: Upgrading codex-rs past the release that removed the key; a stale ~/.codex/config.toml or project .codex/config.toml written by an older version; dotfile repos and team config templates that still ship a `profile` line; CI scripts generating configs from the old schema.

Related errors


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/c65156e791bfa1de. Report an issue: GitHub.