{"record":{"id":"abb6d475f7ba4af9","repo":"dmtrKovalenko/fff","slug":"failed-to-create-fff-file-picker-for-options-bas","errorCode":null,"errorMessage":"Failed to create FFF file picker for ${options.basePath}: ${result.error}","messagePattern":"Failed to create FFF file picker for (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/pi-fff/src/file-picker.ts","lineNumber":40,"sourceCode":"    onDbFailure?: (error: string) => void;\n  }) {\n    this.frecencyDbPath = opts.frecencyDbPath;\n    this.historyDbPath = opts.historyDbPath;\n    this.onDbFailure = opts.onDbFailure;\n  }\n\n  /** True once the databases were given up on, so pickers open without them. */\n  get databasesDisabled(): boolean {\n    return this.dbDisabled;\n  }\n\n  /** Opens a scanned, ready-to-use picker. Throws if it cannot be created. */\n  async create(options: PickerOptions): Promise<FileFinderApi> {\n    const { FileFinder } = await loadSdk();\n    const result = this.openWithDbFallback(FileFinder, options);\n\n    if (!result.ok) {\n      throw new Error(\n        `Failed to create FFF file picker for ${options.basePath}: ${result.error}`,\n      );\n    }\n\n    // waitForScan() also resolves on timeout, so this bounds startup rather\n    // than guaranteeing a complete index.\n    await result.value.waitForScan(SCAN_TIMEOUT_MS);\n    return result.value;\n  }\n\n  private openWithDbFallback(\n    FileFinder: FileFinderStatic,\n    options: PickerOptions,\n  ): Result<FileFinderApi> {\n    const init: InitOptions = { ...options, aiMode: true };\n    if (this.dbDisabled) return FileFinder.create(init);\n\n    const result = FileFinder.create({","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/dmtrKovalenko/fff/blob/7f8537e70f0ea1210f9acbbfc4640141105cdc78/packages/pi-fff/src/file-picker.ts#L22-L58","documentation":"create() opens an FFF FileFinder via the underlying SDK and requires a successful, scanned picker. When openWithDbFallback returns result.ok === false, the SDK's error string is wrapped in this message and thrown, so callers get a single descriptive failure for picker startup problems (bad base path, native library issues, or scan/DB errors surfaced by the SDK).","triggerScenarios":"Calling create({ basePath, ... }) where basePath does not exist or is not a directory, the native fff library cannot load, the SDK result envelope carries an error (e.g. index/DB corruption or permission failure on the base path), or the FFI create call returns { ok: false, error }.","commonSituations":"Typos or relative paths in basePath config, pointing at a deleted/unmounted directory, running without read access to the target folder, or a stale/corrupt frecency DB that even the fallback path cannot recover.","solutions":["Verify options.basePath exists and is a directory before calling create() (fs.existsSync + fs.statSync().isDirectory()).","Read the wrapped ${result.error} in the message — it names the SDK-level cause; fix that underlying issue.","Ensure the native fff library is installed (npx @ff-labs/fff-node download or cargo build --release -p fff-c).","Check read permissions on basePath and that it is on a mounted, accessible filesystem.","If the error points at the DB, clear the fff cache/frecency DB so a fresh index is built."],"exampleFix":"// before\nconst picker = await fff.create({ basePath: cfg.basePath });\n// after\nimport { statSync } from 'fs';\nif (!statSync(cfg.basePath, { throwIfNoEntry: false })?.isDirectory()) {\n  throw new Error(`basePath is not a directory: ${cfg.basePath}`);\n}\nconst picker = await fff.create({ basePath: cfg.basePath });","handlingStrategy":"try-catch","validationCode":"import { statSync } from 'fs';\nconst st = statSync(basePath, { throwIfNoEntry: false });\nif (!st?.isDirectory()) throw new Error(`basePath must be an existing directory: ${basePath}`);","typeGuard":"function isDirectory(p: string): boolean {\n  return statSync(p, { throwIfNoEntry: false })?.isDirectory() ?? false;\n}","tryCatchPattern":"try {\n  const picker = await fff.create({ basePath });\n} catch (e) {\n  if (String(e.message).startsWith('Failed to create FFF file picker')) {\n    console.error('Check basePath exists, is readable, and the native lib is installed:', e.message);\n    // optionally clear the fff DB and retry once\n  } else throw e;\n}","preventionTips":["Always resolve basePath to an absolute, existing directory before create().","Surface the inner result.error from the message to diagnose the SDK-level cause.","Ensure the native binary is installed before picker startup.","Clear the fff index/DB after plugin upgrades if creation keeps failing.","Handle scan-timeout semantics: waitForScan bounds startup but does not guarantee a full index."],"tags":["file-picker","initialization","invalid-path","ffi","pi-fff"],"backgroundTag":"entity-not-found","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"}