zeroclaw-labs/zeroclaw · error · anyhow::Error

--config-dir cannot be empty

Error message

--config-dir cannot be empty

What it means

Early CLI validation in main: fires when the --config-dir option is given but its value is empty or whitespace-only after trimming. An empty config dir would cause config resolution to operate on an invalid path and produce confusing downstream errors, so it is rejected up front. Pass an actual directory path, or omit the flag to use the default.

Solutions

  1. Pass a non-empty path to --config-dir, e.g. `--config-dir ~/.zeroclaw`.
  2. Omit --config-dir to use the default configuration directory.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/main.rs:3473 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/f1b04423b6b67c76. Report an issue: GitHub.

Appendix: source

Thrown at src/main.rs:3473

                "cli-warn-crypto-provider",
                &[("err", &format!("{e:?}"))],
                "Warning: Failed to install default crypto provider"
            )
        );
    }

    let cmd = apply_i18n_to_command(command);

    if std::env::args_os().len() <= 1 {
        return print_no_command_help(cmd);
    }

    let cli = Cli::from_arg_matches(&cmd.get_matches()).map_err(|e| e.exit())?;

    if let Some(config_dir) = &cli.config_dir
        && config_dir.trim().is_empty()
    {
        bail!("--config-dir cannot be empty");
    }

    #[cfg(feature = "agent-runtime")]
    crate::i18n::init(&crate::i18n::detect_locale());

    // Completions must remain stdout-only and should not load config or initialize logging.
    // This avoids warnings/log lines corrupting sourced completion scripts.
    if let Commands::Completions { shell } = &cli.command {
        let mut stdout = std::io::stdout().lock();
        write_shell_completion(*shell, &mut stdout)?;
        return Ok(());
    }

    // Docs-pipeline subcommands: stdout-only, no config load, no logging init.
    match &cli.command {
        Commands::MarkdownHelp => {
            clap_markdown::print_help_markdown::<Cli>();
            return Ok(());

View on GitHub (pinned to 88bb9c8533)