a-b-street/abstreet · error

Invalid --color_scheme=

Error message

Invalid --color_scheme={}. Choices: {}

What it means

The ColorSchemeChoice::parse function maps a user-supplied string (usually the --color_scheme CLI flag) to a ColorScheme by exact label match. If no choice label equals the input, it bails listing all valid choices.

Solutions

  1. Use one of the exact choices printed in the error message (run with --help or read the list).
  2. Fix the spelling/casing in your script or alias.
  3. If a scheme was renamed between versions, update the flag to the new label.

Example fix

// before
./game --color_scheme=nite
// after
./game --color_scheme=night
Defensive patterns

Strategy: validation

Validate before calling

let valid: Vec<&str> = ColorSchemeChoice::choices().iter().map(|c| c.label.as_str()).collect();
if !valid.contains(&scheme.as_str()) {
    bail!("--color_scheme must be one of: {}", valid.join(", "));
}

Try / catch

let scheme = match ColorSchemeChoice::parse(&flag) {
    Ok(s) => s,
    Err(e) => { eprintln!("{e}"); std::process::exit(2); }
};

Prevention

When it happens

Trigger: Launching any map_gui-based game/binary with --color_scheme set to a misspelled or unknown name, e.g. --color_scheme=dark instead of a defined scheme label.

Common situations: Typo in a command line, stale scripts referencing removed/renamed color schemes after upgrades, case mismatches.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of a-b-street/abstreet@0964f29315 (2026-09-13). Data as JSON: /api/errors/bafce024c1b7aff6. Report an issue: GitHub.

Appendix: source

Thrown at map_gui/src/colors.rs:56

    pub fn choices() -> Vec<Choice<ColorSchemeChoice>> {
        vec![
            Choice::new("day mode", ColorSchemeChoice::DayMode),
            Choice::new("night mode", ColorSchemeChoice::NightMode),
            Choice::new("textured", ColorSchemeChoice::Textured),
            Choice::new("classic", ColorSchemeChoice::ClassicDayMode),
            Choice::new("LTN", ColorSchemeChoice::LTN),
        ]
    }

    pub fn parse(x: &str) -> Result<ColorSchemeChoice> {
        let mut options = Vec::new();
        for c in ColorSchemeChoice::choices() {
            options.push(c.label.clone());
            if c.label == x {
                return Ok(c.data);
            }
        }
        bail!(
            "Invalid --color_scheme={}. Choices: {}",
            x,
            options.join(", ")
        );
    }
}

pub struct ColorScheme {
    scheme: ColorSchemeChoice,

    pub road_outlines: bool,
    pub road_class_colors: bool,
    pub show_buildings_in_minimap: bool,

    // UI
    pub panel_bg: Color,
    pub inner_panel_bg: Color,
    pub day_time_slider: Color,

View on GitHub (pinned to 0964f29315)