{"record":{"id":"5734d64e4f84793e","repo":"a-b-street/abstreet","slug":"couldn-t-read","errorCode":null,"errorMessage":"Couldn't read {}","messagePattern":"Couldn't read (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"widgetry/src/runner.rs","lineNumber":227,"sourceCode":"    /// Specify the title of the window to open.\n    pub fn new(window_title: &str) -> Settings {\n        Settings {\n            window_title: window_title.to_string(),\n            #[cfg(target_arch = \"wasm32\")]\n            root_dom_element_id: \"widgetry-canvas\".to_string(),\n            assets_base_url: None,\n            assets_are_gzipped: false,\n            dump_raw_events: false,\n            scale_factor: None,\n            require_minimum_width: None,\n            window_icon: None,\n            loading_tips: None,\n            load_default_textures: true,\n            read_svg: Box::new(|path| {\n                use std::io::Read;\n\n                let mut file =\n                    fs_err::File::open(path).unwrap_or_else(|_| panic!(\"Couldn't read {}\", path));\n                let mut buffer = Vec::new();\n                file.read_to_end(&mut buffer)\n                    .unwrap_or_else(|_| panic!(\"Couldn't read all of {}\", path));\n                buffer\n            }),\n            canvas_settings: CanvasSettings::new(),\n        }\n    }\n\n    /// Log every raw winit event to the DEBUG level.\n    pub fn dump_raw_events(mut self) -> Self {\n        assert!(!self.dump_raw_events);\n        self.dump_raw_events = true;\n        self\n    }\n\n    /// Override the initial HiDPI scale factor from whatever winit initially detects.\n    pub fn scale_factor(mut self, scale_factor: f64) -> Self {","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/a-b-street/abstreet/blob/0964f29315820c91b171b585eb51e300164e9197/widgetry/src/runner.rs#L209-L245","documentation":"The default Settings::read_svg closure panics when the SVG file at the given path cannot be opened (fs_err::File::open fails). It reports \"Couldn't read {path}\" — typically the file doesn't exist or isn't readable at the time an asset is loaded.","triggerScenarios":"Calling load_svg with a path that doesn't exist on disk, a path relative to the wrong working directory, or a file without read permissions, while using the default read_svg implementation in Settings.","commonSituations":"Assets not packaged with the binary (missing from include dir or install bundle), running the app from a different cwd than during development, typos in asset filenames, Linux case-sensitivity vs Windows-authored paths.","solutions":["Verify the path exists relative to the process's current working directory.","Fix the asset path/filename spelling and case.","Ship the asset with the application and reference it correctly in packaging.","Override Settings.read_svg with include_bytes!-based embedding or a custom loader returning empty bytes/own error handling."],"exampleFix":"// before\nlet mut file = fs_err::File::open(path).unwrap_or_else(|_| panic!(\"Couldn't read {}\", path));\n// after\nlet mut file = fs_err::File::open(path).unwrap_or_else(|e| panic!(\"Couldn't read {}: {}\", path, e));","handlingStrategy":"validation","validationCode":"if !std::path::Path::new(path).exists() { eprintln!(\"missing asset: {}\", path); }\n// or at startup, probe all assets:\n// for p in REQUIRED_SVGS { assert!(Path::new(p).exists(), \"missing asset {}\", p); }","typeGuard":null,"tryCatchPattern":"// Provide a custom read_svg that returns empty bytes + logs instead of panicking:\nsettings.read_svg = Box::new(|path| std::fs::read(path).unwrap_or_else(|e| { log::error!(\"{}: {}\", path, e); Vec::new() }));","preventionTips":["Embed assets with include_bytes! or a packaged resource dir","Probe all required asset paths at startup with a clear error listing","Use case-exact filenames for cross-platform builds","Run from a known cwd or resolve asset paths relative to the executable"],"tags":["rust","filesystem","svg","assets"],"backgroundTag":"file-not-found","analyzedSha":"0964f29315820c91b171b585eb51e300164e9197","analyzedAt":"2026-09-13T18:02:03.421Z","contentChangedAt":"2026-09-13T18:02:03.421Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}