dmtrKovalenko/fff · critical

Failed to init file picker

Error message

Failed to init file picker: {}

What it means

This error is returned by fff_create_instance_with when the underlying FilePicker::new initialization fails (e.g. the picker could not scan roots, open its frecency DB, or set up its state). The FFI layer wraps the inner error message and returns an error FffResult to the caller instead of an instance handle.

Solutions

  1. Check the inner error message (the {} payload) to see which subsystem failed to init.
  2. Verify the cwd/scan root paths passed in the options exist and are readable by the process.
  3. Ensure the frecency/database directory is writable (check permissions, disk space, sandbox mounts).
  4. If scanning home dir or fs roots, either disable those flags or grant the process access.
  5. Confirm the FffOptions.version matches what the linked library supports and any new fields are correctly populated.

Example fix

// before: passing a nonexistent cwd
let inst = fff_create_instance_with(c"/does/not/exist", &opts);
// after: verify the path first
if !std::path::Path::new("/does/not/exist").is_dir() {
    eprintln!("scan root missing; falling back to home dir");
}
Defensive patterns

Strategy: fallback

Validate before calling

if not vim.fn.isdirectory(scan_root) then scan_root = vim.fn.getcwd() end

Try / catch

local ok, inst = pcall(fff.create_instance, opts)
if not ok then
  vim.notify('picker init failed: ' .. tostring(inst), vim.log.levels.WARN)
  -- fall back to vim.ui.select or another picker
end

Prevention

When it happens

Trigger: Calling fff_create_instance / fff_create_instance2 / fff_create_instance_with when FilePicker::new returns Err: invalid or non-existent cwd/scan roots, unwritable or corrupt frecency DB location, denied filesystem access to configured scan directories, or an incompatible options version.

Common situations: Passing a deleted or never-accessed working directory; running in a sandbox/container without access to home dir or fs roots while enable_home_dir_scanning/enable_fs_root_scanning are true; LMDB database directory not writable; stale options struct after a library version change (version-gated fields like follow_symlinks).

Related errors


AI-assisted analysis of dmtrKovalenko/fff@7f8537e70f (2026-09-10). Data as JSON: /api/errors/5622983fe81f6b55. Report an issue: GitHub.

Appendix: source

Thrown at crates/fff-c/src/lib.rs:271

        opts.cache_budget_max_file_size,
    );

    if let Err(e) = FilePicker::new_with_shared_state(
        shared_picker.clone(),
        shared_frecency.clone(),
        fff::FilePickerOptions {
            base_path: base_path_str,
            enable_mmap_cache: opts.enable_mmap_cache,
            enable_content_indexing: opts.enable_content_indexing,
            watch: opts.watch,
            mode,
            cache_budget,
            follow_symlinks: opts.version >= 2 && opts.follow_symlinks,
            enable_fs_root_scanning: opts.enable_fs_root_scanning,
            enable_home_dir_scanning: opts.enable_home_dir_scanning,
        },
    ) {
        return FffResult::err(&format!("Failed to init file picker: {}", e));
    }

    let instance = Box::new(FffInstance {
        picker: shared_picker,
        frecency: shared_frecency,
        query_tracker,
        watch_callback: std::sync::Arc::new(watch::WatchCallbackSlot::default()),
    });

    let fff_handle = Box::into_raw(instance) as *mut c_void;
    FffResult::ok_handle(fff_handle)
}

/// [`fff_create_instance_with`] adapter taking [`FffCreateOptions`] **by value**,
/// for FFI libraries that pass native structs by value (e.g. Node's `ffi-rs`).
///
/// ## Safety
/// All `*const c_char` fields inside `opts` must be valid null-terminated

View on GitHub (pinned to 7f8537e70f)