helix-editor/helix · error

Current working directory does not exist

Error message

Current working directory does not exist

What it means

Before :global-search streams results, commands.rs resolves the search root from helix_stdx::env::current_working_dir() — helix's cached CWD (captured at startup or the last :cd, kept because std::env::current_dir() fails once the dir is gone) — and checks .exists(). If that directory was deleted, renamed, or unmounted while helix runs, the picker aborts with this error instead of searching.

Source

Thrown at helix-term/src/commands.rs:2616

        PickerColumn::new("path", |item: &FileResult, config: &GlobalSearchConfig| {
            config
                .style
                .stylize(Some(&item.path), Some(item.line_start))
        }),
        PickerColumn::hidden("contents"),
    ];

    let get_files = |query: &str,
                     editor: &mut Editor,
                     config: std::sync::Arc<GlobalSearchConfig>,
                     injector: &ui::picker::Injector<_, _>| {
        if query.is_empty() {
            return async { Ok(()) }.boxed();
        }

        let search_root = helix_stdx::env::current_working_dir();
        if !search_root.exists() {
            return async { Err(anyhow::anyhow!("Current working directory does not exist")) }
                .boxed();
        }

        let documents: Vec<_> = editor
            .documents()
            .map(|doc| (doc.path().map(ToOwned::to_owned), doc.text().to_owned()))
            .collect();

        let matcher = match RegexMatcherBuilder::new()
            .case_smart(config.smart_case)
            .multi_line(true)
            .build(query)
        {
            Ok(matcher) => {
                // Clear any "Failed to compile regex" errors out of the statusline.
                editor.clear_status();
                matcher
            }

View on GitHub (pinned to 079a789e8c)

Solutions

  1. Run `:cd <existing-dir>` (updates the cached CWD) and retry :global-search.
  2. If the project moved or the old path is gone for good, exit and restart helix from a valid directory.
  3. If the path should exist, recreate it (mkdir -p) and retry.
Defensive patterns

Strategy: validation

Validate before calling

let root = helix_stdx::env::current_working_dir();
if !root.exists() {
    // prompt `:cd <valid-dir>` instead of running :global-search
}

Prevention

When it happens

Trigger: Start hx inside a directory, remove it from another terminal (rm -rf, git worktree remove, deleted release dir), then invoke :global-search with any query.

Common situations: Editing in /tmp or scratch dirs that cleaners remove; git worktrees deleted from another session; container/pod volumes unmounted or replaced during a deploy while an editor stayed open.

Related errors


AI-assisted analysis of helix-editor/helix@079a789e8c (2026-08-16). Data as JSON: /api/errors/71a823d93ce712fc. Report an issue: GitHub.