{"record":{"id":"2028d04f67ee0d26","repo":"lsd-rs/lsd","slug":"provided-file-path-is-invalid","errorCode":null,"errorMessage":"Provided file path is invalid","messagePattern":"Provided file path is invalid","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main.rs","lineNumber":122,"sourceCode":"                std::process::exit(0);\n            }\n        }\n    };\n}\n\nfn main() {\n    let cli = Cli::parse_from(wild::args_os());\n\n    // Handle --generate-config flag\n    if cli.generate_config {\n        generate_default_config();\n        std::process::exit(0);\n    }\n\n    let config = if cli.ignore_config {\n        Config::with_none()\n    } else if let Some(path) = &cli.config_file {\n        Config::from_file(path).expect(\"Provided file path is invalid\")\n    } else {\n        Config::default()\n    };\n    let flags = Flags::configure_from(&cli, &config).unwrap_or_else(|err| err.exit());\n    let core = Core::new(flags);\n\n    let exit_code = core.run(cli.inputs);\n    std::process::exit(exit_code as i32);\n}\n\nfn generate_default_config() {\n    use crate::config_file;\n\n    // Print the default config to stdout without the leading '---'\n    let config = config_file::DEFAULT_CONFIG.trim_start_matches(\"---\\n\");\n    println!(\"{}\", config);\n}\n","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/lsd-rs/lsd/blob/4b6c14a110fe0fd544ec0204501b5fd3a5d6218f/src/main.rs#L104-L140","documentation":"In main, when --config <path> is supplied, Config::from_file(path) is unwrapped with .expect(\"Provided file path is invalid\"). from_file returns None when the path cannot be read or the file fails to parse into a Config, so this panic means the user passed a config path that does not exist, is unreadable, or contains invalid YAML.","triggerScenarios":"Running eza with eza --config <path> where the path is missing, has wrong permissions, is a directory, or the file contains YAML that does not deserialize into Config.","commonSituations":"Typo in the config path; shell variable expanding to empty ($XDG_CONFIG_HOME unset); config written for an older eza version with renamed/removed keys; pointing --config at a directory or a config for a different tool.","solutions":["Verify the path exists and is readable: ls -l <path> / cat <path>; fix typos and permissions.","Validate the file's YAML parses as eza config (compare with the documented config format / default config).","Update renamed or removed config keys to match your installed eza version (check eza --help or release notes).","As a workaround, start without --config (use Config::default()) or with --ignore-config."],"exampleFix":"// before\nlet config = Config::from_file(path).expect(\"Provided file path is invalid\");\n// after\nif !path.is_file() {\n    eprintln!(\"config file not found: {}\", path.display());\n    std::process::exit(1);\n}\nlet config = Config::from_file(path).unwrap_or_else(|| {\n    eprintln!(\"failed to parse config: {}\", path.display());\n    std::process::exit(1);\n});","handlingStrategy":"validation","validationCode":"let path = std::path::Path::new(cli.config_file);\nif !path.is_file() {\n    eprintln!(\"config file not found: {}\", path.display());\n    std::process::exit(1);\n}\nlet contents = std::fs::read_to_string(path)\n    .expect(\"config file unreadable\");\nassert!(serde_yaml::from_str::<Config>(&contents).is_ok(), \"invalid config YAML\");","typeGuard":"fn is_valid_config_path(p: &str) -> bool {\n    std::path::Path::new(p).is_file()\n}","tryCatchPattern":"let config = Config::from_file(path).unwrap_or_else(|| {\n    eprintln!(\"Provided file path is invalid: {}\", path.display());\n    std::process::exit(1);\n});","preventionTips":["Always check the config path exists with is_file() before passing --config.","Quote variables in shell to avoid empty expansions: eza --config \"$CONFIG\".","Validate the config YAML with a parser or eza --ignore-config A/B test after edits.","Re-check config keys after upgrading eza; remove renamed/deprecated options."],"tags":["cli","config","panic","file-not-found"],"backgroundTag":"config-file-not-found","analyzedSha":"4b6c14a110fe0fd544ec0204501b5fd3a5d6218f","analyzedAt":"2026-09-04T20:04:26.847Z","contentChangedAt":"2026-09-04T20:04:26.847Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}