Repository: promptfoo/promptfoo
Issue: seeing `Database migration failed: Error: Could not locate the bindings file` for 0.119.14 release
Root cause: Environment Incompatibility



```
  ==> /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/bin/promptfoo init --no-interactive
  Database migration failed: Error: Could not locate the bindings file. Tried:
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/build/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/build/Debug/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/build/Release/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/out/Debug/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/Debug/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/out/Release/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/Release/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/build/default/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/compiled/25.2.1/linux/arm64/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/addon-build/release/install-root/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/addon-build/debug/install-root/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/addon-build/default/install-root/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/lib/binding/node-v141-linux-arm64/better_sqlite3.node
  /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/bindings/bindings.js:126
    err = new Error(
          ^
  
  Error: Could not locate the bindings file. Tried:
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/build/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/build/Debug/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/build/Release/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/out/Debug/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/Debug/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/out/Release/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/Release/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/build/default/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/compiled/25.2.1/linux/arm64/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/addon-build/release/install-root/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/addon-build/debug/install-root/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/addon-build/default/install-root/better_sqlite3.node
   → /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/lib/binding/node-v141-linux-arm64/better_sqlite3.node
      at bindings (/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/bindings/bindings.js:126:9)
      at new Database (/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/lib/database.js:48:64)
      at getDb (/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/dist/src/database/index.js:73:26)
      at Immediate.<anonymous> (/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/dist/src/migrate.js:56:46)
      at process.processImmediate (node:internal/timers:504:21) {
    tries: [
      '/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/build/better_sqlite3.node',
      '/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/build/Debug/better_sqlite3.node',
      '/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/build/Release/better_sqlite3.node',
      '/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/out/Debug/better_sqlite3.node',
      '/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/Debug/better_sqlite3.node',
      '/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/out/Release/better_sqlite3.node',
      '/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/Release/better_sqlite3.node',
      '/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/build/default/better_sqlite3.node',
      '/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/compiled/25.2.1/linux/arm64/better_sqlite3.node',
      '/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/addon-build/release/install-root/better_sqlite3.node',
      '/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/addon-build/debug/install-root/better_sqlite3.node',
      '/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/addon-build/default/install-root/better_sqlite3.node',
      '/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/lib/binding/node-v141-linux-arm64/better_sqlite3.node'
    ]
  }
  
  Node.js v25.2.1
```

- https://github.com/Homebrew/homebrew-core/pull/256634

<!-- linear-linkback -->
<p><a href="https://linear.app/promptfooo/issue/ENG-1180/seeing-database-migration-failed-error-could-not-locate-the-bindings">ENG-1180</a></p>

Hi @chenrui333, thank you for submitting the bug report. I tried reproducing this on both my mac and linux machines with node 25 and the homebrew version of promptfoo but couldn't reproduce. Could you check a few things for me?

1. Check whether the better-sqlite3 binding exists:
```
ls /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/build/Release/better_sqlite3.node
```

2. Try rebuilding the binding (requires python3/gcc/make):
```
    cd /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo && npm rebuild better-sqlite3 --build-from-source
```

If that fails, please post the log here.

If you don't want to workaround this by using the npm version of promptfoo, please also try `brew reinstall promptfoo --build-from-source`.


It seems that the better-sqlite3 binding is missing in your installation - trying to figure out if the install scripts never ran, or the prebuild download failed.

> 1. Check whether the better-sqlite3 binding exists:
> 
> ```
> ls /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/build/Release/better_sqlite3.node
> ```

this is what I can see

```
$ fd sqlite3 /home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14
/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/
/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/deps/sqlite3/
/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/deps/sqlite3/sqlite3.c
/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/deps/sqlite3/sqlite3.h
/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/deps/sqlite3/sqlite3ext.h
/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/deps/sqlite3.gyp
/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/better-sqlite3/src/better_sqlite3.cpp
/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/drizzle-orm/better-sqlite3/
/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec/lib/node_modules/promptfoo/node_modules/drizzle-orm/libsql/sqlite3/
```

I think the reason why is we disabled `--ignore-scripts` for the npm installation on the homebrew side

```
==> npm install --loglevel=silly --global --build-from-source --cache=/home/runner/.cache/Homebrew/npm_cache --prefix=/home/linuxbrew/.linuxbrew/Cellar/promptfoo/0.119.14/libexec /var/tmp/promptfoo-20251204-26015-rwewe3/package/promptfoo-0.119.14.tgz --ignore-scripts
```

- https://github.com/Homebrew/brew/pull/21136

> * std_npm_args: ignore scripts optionally, by default. Homebrew/brew#21136

that is the thing. should be good now.