From b0a14b18ad64c24817174aba84f10c008fb807dd Mon Sep 17 00:00:00 2001 From: Syed Humair Date: Wed, 11 Mar 2026 05:24:44 +0400 Subject: [PATCH] fix: remove $BUN_INSTALL check from launcher to prevent false Bun detection When Bun is installed on the system but QMD was installed via npm, $BUN_INSTALL is always set (typically to ~/.bun), causing the launcher to incorrectly run QMD under Bun. This leads to ABI mismatches with native modules (better-sqlite3, sqlite-vec) that were compiled for Node, breaking vector operations with "no such module: vec0". Only check for bun.lock/bun.lockb files, which reliably indicate that QMD was actually installed with Bun. Fixes #361 Co-Authored-By: Claude Opus 4.6 --- bin/qmd | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/qmd b/bin/qmd index 967641f..679e168 100755 --- a/bin/qmd +++ b/bin/qmd @@ -15,8 +15,12 @@ done # to avoid native module ABI mismatches (e.g., better-sqlite3 compiled for bun vs node) DIR="$(cd -P "$(dirname "$SOURCE")/.." && pwd)" -# Check if we were installed with bun (look for bun.lock or bun-lockb) -if [ -f "$DIR/bun.lock" ] || [ -f "$DIR/bun.lockb" ] || [ -n "$BUN_INSTALL" ]; then +# Check if we were installed with bun (look for bun.lock or bun-lockb). +# $BUN_INSTALL is intentionally NOT checked here — it only indicates that bun +# exists on the system, not that it was used to install this package. When QMD +# is installed via npm, native modules are compiled for Node and running them +# under bun causes ABI mismatches (e.g. sqlite-vec "no such module: vec0"). +if [ -f "$DIR/bun.lock" ] || [ -f "$DIR/bun.lockb" ]; then exec bun "$DIR/dist/cli/qmd.js" "$@" else exec node "$DIR/dist/cli/qmd.js" "$@"