a-b-street/abstreet · error
Bad --alerts= . Must be print|block|silence
Error message
Bad --alerts={}. Must be print|block|silence What it means
This error comes from the CLI argument parser for the --alerts flag in the simulator. The flag controls how in-game alerts are handled, and it accepts exactly three values: print, block, or silence. Any other string fails with this message, echoing the bad value and the valid choices.
Solutions
- Change the --alerts value to exactly one of print, block, or silence
- Check for case sensitivity and stray whitespace in the flag value
- If you need a new handler, add a match arm in parse_alert_handler in sim/src/sim/mod.rs
Example fix
// before --alerts=Blocks // after --alerts=block
Defensive patterns
Strategy: validation
Validate before calling
const VALID_ALERTS: [&str; 3] = ["print", "block", "silence"];
if !VALID_ALERTS.contains(&alerts.as_str()) {
eprintln!("--alerts must be print|block|silence, got: {}", alerts);
std::process::exit(2);
} Type guard
fn is_valid_alert_handler(x: &str) -> bool {
matches!(x, "print" | "block" | "silence")
} Prevention
- Wrap simulator invocations in a script that validates flags before launch
- Use an enum-typed CLI parser (e.g. clap with ValueEnum) instead of raw string matching
- Add a shell-completion or help text listing the three valid values
When it happens
Trigger: Calling the sim binary (or SimOptions parsing path) with --alerts set to anything other than print, block, or silence, including typos like 'blockq', capitalized 'Print', or an empty string.
Common situations: Typos in shell scripts or run configs, copy-pasting flag values from docs of other tools, environment-specific wrappers that interpolate an unexpected value into --alerts.
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/c9424435f59812bb.
Report an issue: GitHub.
Appendix: source
Thrown at sim/src/sim/mod.rs:182
Print,
/// Print the alert to STDOUT and don't proceed until the UI calls clear_alerts()
Block,
/// Don't do anything
Silence,
}
impl Default for AlertHandler {
fn default() -> AlertHandler {
AlertHandler::Print
}
}
fn parse_alert_handler(x: &str) -> Result<AlertHandler> {
match x {
"print" => Ok(AlertHandler::Print),
"block" => Ok(AlertHandler::Block),
"silence" => Ok(AlertHandler::Silence),
_ => bail!("Bad --alerts={}. Must be print|block|silence", x),
}
}
// Setup
impl Sim {
pub fn new(map: &Map, mut opts: SimOptions) -> Sim {
let mut timer = Timer::new("create blank sim");
let mut scheduler = Scheduler::new();
// Always disable parking for two maps. See
// https://github.com/a-b-street/abstreet/issues/688 for discussion of how to set this
// properly.
if map.get_name() == &MapName::seattle("arboretum")
|| map.get_name().city == CityName::new("ir", "tehran")
|| map.get_name() == &MapName::new("gb", "poundbury", "center")
|| map.get_name() == &MapName::new("us", "phoenix", "tempe")
|| map.get_name() == &MapName::new("br", "sao_paulo", "sao_miguel_paulista")
{View on GitHub (pinned to 0964f29315)