{"record":{"id":"e3db8621d3c70017","repo":"sinelaw/fresh","slug":"failed-to-load-config-from","errorCode":null,"errorMessage":"Failed to load config from {}: {}","messagePattern":"Failed to load config from (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fresh-editor/src/main.rs","lineNumber":1900,"sourceCode":"    // (no setEnv → restart flicker on a re-open, issue #2280).\n    env_provider.set_store(\n        Some(fresh::services::env_provider::EnvStore::for_project_dir(\n            &dir_context.project_state_dir(&effective_working_dir),\n        )),\n        workspace_trust.level() == fresh::services::workspace_trust::TrustLevel::Trusted,\n    );\n\n    let mut config = if let Some(config_path) = &args.config {\n        // Explicit config file overrides layered system\n        match config::Config::load_from_file(config_path) {\n            Ok(cfg) => cfg,\n            Err(e) => {\n                eprintln!(\n                    \"Error: Failed to load config from {}: {}\",\n                    config_path.display(),\n                    e\n                );\n                anyhow::bail!(io::Error::new(io::ErrorKind::InvalidData, e.to_string()));\n            }\n        }\n    } else {\n        config::Config::load_with_layers(&dir_context, &effective_working_dir)\n    };\n\n    tracing::info!(\"Config loaded\");\n    config.apply_runtime_flags();\n\n    // CLI flag overrides config\n    if args.no_upgrade_check {\n        config.check_for_updates = false;\n    }\n\n    // Initialize i18n with locale: CLI arg > config > environment\n    // This ensures menu defaults are created with the correct translations\n    fresh::i18n::init_with_config(resolve_locale_override(args, &config));\n","sourceCodeStart":1882,"sourceCodeEnd":1918,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor/src/main.rs#L1882-L1918","documentation":"Not a bail string itself: when loading the user config file fails, main.rs prints \"Error: Failed to load config from <path>: <reason>\" and then bails with an InvalidData io::Error carrying the same message. It signals the editor could not start because its configuration file is unreadable or malformed.","triggerScenarios":"Config file at the resolved config_path fails to parse or load (invalid TOML/JSON, wrong types, unreadable file); the explicit config path passed via CLI does not contain valid config.","commonSituations":"Hand-editing config and introducing a syntax error; a config written by a newer Fresh version containing unknown/invalid keys; wrong file permissions; pointing --config at a non-config file.","solutions":["Read the underlying reason after the colon and fix that line/key in the config file.","Validate the file parses (e.g. run it through a TOML/JSON linter).","Temporarily move the config aside to confirm it is the cause, then restore keys incrementally.","Fix file permissions if the error is access-related."],"exampleFix":"# before (config.toml)\ntheme = fresh-dark\nfont_size = \"big\"\n# after\ntheme = \"fresh-dark\"\nfont_size = 14","handlingStrategy":"validation","validationCode":"// validate config before launching\nconst toml = require('toml');\nconst fs = require('fs');\nconst path = process.env.HOME + '/.config/fresh/config.toml';\ntry { toml.parse(fs.readFileSync(path, 'utf8')); }\ncatch (e) { console.error(`Invalid config at ${path}: ${e.message}`); process.exit(1); }","typeGuard":null,"tryCatchPattern":"// rust\nmatch Config::load(&path) {\n    Ok(cfg) => cfg,\n    Err(e) => { eprintln!(\"config invalid at {}: {e}\", path.display()); std::process::exit(1); }\n}","preventionTips":["Lint your config (taplo/tomll for TOML) after every hand edit.","Change one key at a time and relaunch to localize breakage.","Keep config in version control to diff/rollback bad edits.","Check permissions when configs are managed by dotfile managers."],"tags":["config","startup","parse-error"],"backgroundTag":"config-file-not-found","analyzedSha":"67894ca5463dbd7a89bb31add4627c27d6b79d83","analyzedAt":"2026-09-13T15:04:03.701Z","contentChangedAt":"2026-09-13T15:04:03.701Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}