Hmbown/CodeWhale · error · anyhow::Error

--http and --mobile are mutually exclusive; choose one

Error message

--http and --mobile are mutually exclusive; choose one

What it means

validate_serve_mode_selection enforces the serve flag matrix before any server starts. --http and --mobile both select the HTTP server but with different bind defaults (--mobile rebinds to 0.0.0.0 for LAN reachability), so passing both is ambiguous and rejected outright; exactly one transport mode must be chosen.

Source

Thrown at crates/tui/src/lib.rs:1284

            host,
            mobile_rebound_to_lan: false,
        },
        (false, None) => ServeBindHost {
            host: "127.0.0.1".to_string(),
            mobile_rebound_to_lan: false,
        },
    }
}

fn validate_serve_mode_selection(
    mcp: bool,
    http: bool,
    mobile: bool,
    web: bool,
    acp: bool,
) -> Result<bool> {
    if http && mobile {
        bail!("--http and --mobile are mutually exclusive; choose one");
    }
    if web && (http || mobile) {
        bail!("--web is mutually exclusive with --http and --mobile");
    }
    let http_selected = http || mobile || web;
    let selected_modes = [mcp, http_selected, acp]
        .into_iter()
        .filter(|selected| *selected)
        .count();
    if selected_modes != 1 {
        bail!("Choose exactly one server mode: --mcp, --http/--mobile/--web, or --acp");
    }
    Ok(http_selected)
}

#[derive(Subcommand, Debug, Clone)]
enum McpCommand {
    /// List configured MCP servers

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Pick one: `--http` for loopback-only API server, `--mobile` for the LAN-reachable mobile control page
  2. If you copied the command, delete the stale flag
  3. Audit wrapper scripts that OR several serve flags together

Example fix

# before
codewhale serve --http --mobile

# after
codewhale serve --mobile        # or: codewhale serve --http
Defensive patterns

Strategy: validation

Validate before calling

# Assert at most one HTTP flavor before serving
flags=()
$HTTP  && flags+=(--http)
$MOBILE && flags+=(--mobile)
[ "${#flags[@]}" -gt 1 ] && { echo 'pick one of --http/--mobile'; exit 2; }
codewhale serve "${flags[@]}"

Type guard

fn http_flavor_unique(http: bool, mobile: bool) -> bool {
    !(http && mobile)
}

Prevention

When it happens

Trigger: `codewhale serve --http --mobile` (or any wrapper/script that concatenates both flags); copy-pasted command lines from docs that combine the two; CI matrices that set both flags when only one was intended.

Common situations: Migrating a command from --http to --mobile and leaving the old flag in place; shell scripts building flags conditionally where both conditions evaluate true.

Understand the failure class

Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/8b5662c8e25661d7. Report an issue: GitHub.