a-b-street/abstreet · error
bad map path
Error message
bad map path: {} What it means
map_gui's map_name derives the MapName either from the stored map_path (via MapName::from_path) or from the default maps.json in the player data directory. If a map_path is set but cannot be parsed into a MapName, it panics with "bad map path: {path}". from_path returns Option (no error detail), so the panic fires for any unparseable path.
Solutions
- Check the map path matches MapName::from_path's expected format (importer-generated map under the standard data dir with the conventional filename).
- Use the app's map picker / change_map_btn to select a valid imported map instead of typing the path.
- Re-import the map with the importer so it lands in the canonical location with a canonical name.
- Patch from_path to return Result with a reason, or fall back to the default map instead of panicking.
Example fix
// before
MapName::from_path(path).unwrap_or_else(|| panic!("bad map path: {}", path))
// after
match MapName::from_path(path) {
Some(name) => name,
None => {
eprintln!("unrecognized map path {}, using default", path);
default_map_name()
}
} Defensive patterns
Strategy: validation
Validate before calling
let path = std::env::args().find(|a| a.starts_with("--map"));
if let Some(p) = path {
assert!(std::path::Path::new(&p).is_file(), "map file missing: {}", p);
} Try / catch
// Panics uncatchably; pre-narrow the path yourself:
fn valid_map_path(p: &str) -> Option<MapName> {
MapName::from_path(p).or_else(|| {
eprintln!("bad map path {}, falling back to default", p);
None
})
} Prevention
- Only pass importer-generated map paths that live under the standard data/maps directory.
- Use the in-app map picker rather than hand-typing CLI paths.
- Don't rename or relocate imported map .bin files after generation.
When it happens
Trigger: Launching the app with a --map path (or loading a saved map_path) whose filename doesn't match the expected `<name>.bin`-style layout that MapName::from_path understands — e.g. wrong directory structure, missing city/country components, or a renamed map file.
Common situations: Passing an arbitrary OSM/other .bin file not produced by the importer; moving map files out of the expected data/maps directory; typos in the CLI flag; maps.json absent while map_path is also unset is a separate path — here map_path IS set but malformed.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- This build of A/B Street stores player data in…
- Can't find the data/ directory
- CityName::new( , ) has a country code that isn't two letters
- Couldn't read_json( )
- Couldn't read_binary
AI-assisted analysis of a-b-street/abstreet@0964f29315 (2026-09-13).
Data as JSON: /api/errors/ba3d09e00ebe525a.
Report an issue: GitHub.
Appendix: source
Thrown at map_gui/src/simple_app.rs:84
opts.toggle_day_night_colors = false;
}
}
pub fn update_widgetry_settings(&self, mut settings: Settings) -> Settings {
settings = settings
.read_svg(Box::new(abstio::slurp_bytes))
.window_icon(abstio::path("system/assets/pregame/icon.png"));
if let Some(s) = self.scale_factor {
settings = settings.scale_factor(s);
}
settings
}
pub fn map_name(&self) -> MapName {
self.map_path
.as_ref()
.map(|path| {
MapName::from_path(path).unwrap_or_else(|| panic!("bad map path: {}", path))
})
.or_else(|| {
abstio::maybe_read_json::<crate::tools::DefaultMap>(
abstio::path_player("maps.json"),
&mut Timer::throwaway(),
)
.ok()
.map(|x| x.last_map)
})
.unwrap_or_else(|| MapName::seattle("montlake"))
}
}
impl<T: 'static> SimpleApp<T> {
pub fn new<
F: 'static + Fn(&mut EventCtx, &mut SimpleApp<T>) -> Vec<Box<dyn State<SimpleApp<T>>>>,
>(
ctx: &mut EventCtx,View on GitHub (pinned to 0964f29315)