{"record":{"id":"5622983fe81f6b55","repo":"dmtrKovalenko/fff","slug":"failed-to-init-file-picker","errorCode":null,"errorMessage":"Failed to init file picker: {}","messagePattern":"Failed to init file picker: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/fff-c/src/lib.rs","lineNumber":271,"sourceCode":"        opts.cache_budget_max_file_size,\n    );\n\n    if let Err(e) = FilePicker::new_with_shared_state(\n        shared_picker.clone(),\n        shared_frecency.clone(),\n        fff::FilePickerOptions {\n            base_path: base_path_str,\n            enable_mmap_cache: opts.enable_mmap_cache,\n            enable_content_indexing: opts.enable_content_indexing,\n            watch: opts.watch,\n            mode,\n            cache_budget,\n            follow_symlinks: opts.version >= 2 && opts.follow_symlinks,\n            enable_fs_root_scanning: opts.enable_fs_root_scanning,\n            enable_home_dir_scanning: opts.enable_home_dir_scanning,\n        },\n    ) {\n        return FffResult::err(&format!(\"Failed to init file picker: {}\", e));\n    }\n\n    let instance = Box::new(FffInstance {\n        picker: shared_picker,\n        frecency: shared_frecency,\n        query_tracker,\n        watch_callback: std::sync::Arc::new(watch::WatchCallbackSlot::default()),\n    });\n\n    let fff_handle = Box::into_raw(instance) as *mut c_void;\n    FffResult::ok_handle(fff_handle)\n}\n\n/// [`fff_create_instance_with`] adapter taking [`FffCreateOptions`] **by value**,\n/// for FFI libraries that pass native structs by value (e.g. Node's `ffi-rs`).\n///\n/// ## Safety\n/// All `*const c_char` fields inside `opts` must be valid null-terminated","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/dmtrKovalenko/fff/blob/7f8537e70f0ea1210f9acbbfc4640141105cdc78/crates/fff-c/src/lib.rs#L253-L289","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Check the inner error message (the {} payload) to see which subsystem failed to init.","Verify the cwd/scan root paths passed in the options exist and are readable by the process.","Ensure the frecency/database directory is writable (check permissions, disk space, sandbox mounts).","If scanning home dir or fs roots, either disable those flags or grant the process access.","Confirm the FffOptions.version matches what the linked library supports and any new fields are correctly populated."],"exampleFix":"// before: passing a nonexistent cwd\nlet inst = fff_create_instance_with(c\"/does/not/exist\", &opts);\n// after: verify the path first\nif !std::path::Path::new(\"/does/not/exist\").is_dir() {\n    eprintln!(\"scan root missing; falling back to home dir\");\n}","handlingStrategy":"fallback","validationCode":"if not vim.fn.isdirectory(scan_root) then scan_root = vim.fn.getcwd() end","typeGuard":null,"tryCatchPattern":"local ok, inst = pcall(fff.create_instance, opts)\nif not ok then\n  vim.notify('picker init failed: ' .. tostring(inst), vim.log.levels.WARN)\n  -- fall back to vim.ui.select or another picker\nend","preventionTips":["Validate scan roots and cwd exist before instance creation.","Ensure the frecency DB directory is writable in sandboxes/containers.","Keep options struct version in sync with the linked library."],"tags":["ffi","initialization","file-picker","rust"],"backgroundTag":"module-init-failed","analyzedSha":"7f8537e70f0ea1210f9acbbfc4640141105cdc78","analyzedAt":"2026-09-10T07:26:53.407Z","contentChangedAt":"2026-09-10T07:26:53.407Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}