openai/codex · error · anyhow::Error

at least one search directory is required

Error message

at least one search directory is required

What it means

Guard in create_session that rejects an empty search_directories list: the first entry is used as the primary search directory, so a session cannot be created without at least one directory. The caller passed an empty Vec.

Solutions

  1. Pass at least one existing directory in search_directories
  2. Default to the workspace root when no directory is otherwise known
  3. Validate the directory list at the call site before invoking create_session
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at codex-rs/file-search/src/lib.rs:179 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/4f89510d368db3e7. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/file-search/src/lib.rs:179

    }
}

pub fn create_session(
    search_directories: Vec<PathBuf>,
    options: FileSearchOptions,
    reporter: Arc<dyn SessionReporter>,
    cancel_flag: Option<Arc<AtomicBool>>,
) -> anyhow::Result<FileSearchSession> {
    let FileSearchOptions {
        limit,
        exclude,
        threads,
        compute_indices,
        respect_gitignore,
    } = options;

    let Some(primary_search_directory) = search_directories.first() else {
        anyhow::bail!("at least one search directory is required");
    };
    let override_matcher = build_override_matcher(primary_search_directory, &exclude)?;
    let (work_tx, work_rx) = unbounded();

    let notify_tx = work_tx.clone();
    let notify = Arc::new(move || {
        let _ = notify_tx.send(WorkSignal::NucleoNotify);
    });
    let nucleo = Nucleo::new(
        Config::DEFAULT.match_paths(),
        notify,
        Some(threads.get()),
        1,
    );
    let injector = nucleo.injector();

    let cancelled = cancel_flag.unwrap_or_else(|| Arc::new(AtomicBool::new(false)));

View on GitHub (pinned to 339751715c)