sinelaw/fresh · error

Failed to load config from

Error message

Failed to load config from {}: {}

What it means

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.

Solutions

  1. Read the underlying reason after the colon and fix that line/key in the config file.
  2. Validate the file parses (e.g. run it through a TOML/JSON linter).
  3. Temporarily move the config aside to confirm it is the cause, then restore keys incrementally.
  4. Fix file permissions if the error is access-related.

Example fix

# before (config.toml)
theme = fresh-dark
font_size = "big"
# after
theme = "fresh-dark"
font_size = 14
Defensive patterns

Strategy: validation

Validate before calling

// validate config before launching
const toml = require('toml');
const fs = require('fs');
const path = process.env.HOME + '/.config/fresh/config.toml';
try { toml.parse(fs.readFileSync(path, 'utf8')); }
catch (e) { console.error(`Invalid config at ${path}: ${e.message}`); process.exit(1); }

Try / catch

// rust
match Config::load(&path) {
    Ok(cfg) => cfg,
    Err(e) => { eprintln!("config invalid at {}: {e}", path.display()); std::process::exit(1); }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Config file not found": what it means and how to fix it in docker-sync, Maven, Vagrant, Turborepo and other tools — this error's family across 60 libraries.

Related errors


AI-assisted analysis of sinelaw/fresh@67894ca546 (2026-09-13). Data as JSON: /api/errors/e3db8621d3c70017. Report an issue: GitHub.

Appendix: source

Thrown at crates/fresh-editor/src/main.rs:1900

    // (no setEnv → restart flicker on a re-open, issue #2280).
    env_provider.set_store(
        Some(fresh::services::env_provider::EnvStore::for_project_dir(
            &dir_context.project_state_dir(&effective_working_dir),
        )),
        workspace_trust.level() == fresh::services::workspace_trust::TrustLevel::Trusted,
    );

    let mut config = if let Some(config_path) = &args.config {
        // Explicit config file overrides layered system
        match config::Config::load_from_file(config_path) {
            Ok(cfg) => cfg,
            Err(e) => {
                eprintln!(
                    "Error: Failed to load config from {}: {}",
                    config_path.display(),
                    e
                );
                anyhow::bail!(io::Error::new(io::ErrorKind::InvalidData, e.to_string()));
            }
        }
    } else {
        config::Config::load_with_layers(&dir_context, &effective_working_dir)
    };

    tracing::info!("Config loaded");
    config.apply_runtime_flags();

    // CLI flag overrides config
    if args.no_upgrade_check {
        config.check_for_updates = false;
    }

    // Initialize i18n with locale: CLI arg > config > environment
    // This ensures menu defaults are created with the correct translations
    fresh::i18n::init_with_config(resolve_locale_override(args, &config));

View on GitHub (pinned to 67894ca546)