ethanniser / the-beth-stack

An opinionated hypermedia-driven architecture for building web apps
MIT License
848 stars 81 forks source link

better-sqlite3 error: Could not locate the bindings file #6

Closed calebkish closed 1 year ago

calebkish commented 1 year ago

bun version: 1.0.0 platform: arch linux 6.5.2-arch1-1 (btw)

steps to reproduce:

git clone https://github.com/ethanniser/the-beth-stack.git
bun install
echo "DATABASE_URL=file:test.db" > .env
bun run dev
the-beth-stack % bun run dev
$ concurrently "bun run --watch src/index.tsx" "bun run tw:dev"
[1] $ bunx tailwindcss -i ./src/styles.css -o ./tailwind-gen/styles.css --watch
[0] [0.01ms] ".env"
[0] 121 |         throw e;
[0] 122 |       }
[0] 123 |     }
[0] 124 |   }
[0] 125 | 
[0] 126 |   err = new Error(
[0]             ^
[0] error: Could not locate the bindings file. Tried:
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/build/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/build/Debug/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/build/Release/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/out/Debug/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/Debug/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/out/Release/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/Release/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/build/default/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/compiled/18.15.0/linux/x64/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/addon-build/release/install-root/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/addon-build/debug/install-root/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/addon-build/default/install-root/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/lib/binding/node-v108-linux-x64/better_sqlite3.node
[0]       at bindings (/home/caleb/prog/the-beth-stack/node_modules/bindings/bindings.js:126:8)
[0]       at new Database (/home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/lib/database.js:48:28)
[0]       at _createClient (/home/caleb/prog/the-beth-stack/node_modules/@libsql/client/lib-esm/sqlite3.js:34:15)
[0]       at /home/caleb/prog/the-beth-stack/src/db/index.ts:5:15
[0] 121 |         throw e;
[0] 122 |       }
[0] 123 |     }
[0] 124 |   }
[0] 125 | 
[0] 126 |   err = new Error(
[0]             ^
[0] error: Could not locate the bindings file. Tried:
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/build/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/build/Debug/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/build/Release/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/out/Debug/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/Debug/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/out/Release/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/Release/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/build/default/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/compiled/18.15.0/linux/x64/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/addon-build/release/install-root/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/addon-build/debug/install-root/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/addon-build/default/install-root/better_sqlite3.node
[0]  → /home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/lib/binding/node-v108-linux-x64/better_sqlite3.node
[0]       at bindings (/home/caleb/prog/the-beth-stack/node_modules/bindings/bindings.js:126:8)
[0]       at new Database (/home/caleb/prog/the-beth-stack/node_modules/better-sqlite3/lib/database.js:48:28)
[0]       at _createClient (/home/caleb/prog/the-beth-stack/node_modules/@libsql/client/lib-esm/sqlite3.js:34:15)
[0]       at /home/caleb/prog/the-beth-stack/src/db/index.ts:5:15
[1] 
[1] Rebuilding...
[1] 
[1] Done in 176ms.

fwiw, I'm not encountering this issue when running on node instead of bun.

ethanniser commented 1 year ago

Thank you for making this issue It seems bun 1.0 may have broke some compatibility with some of the turso stuff I will ask in the turso discord if they know a fix

ethanniser commented 1 year ago

@calebkish image

not the same exact issue, but same root problem... bun

heres the link to make an issue- https://github.com/libsql/libsql-client-ts the turso people are working hard to help, if any code changes are required here when they get a fix in lmk

arjunindia commented 1 year ago

I believe the problem here is that file urls use better-sqlite3, which uses the native V8 bindings - not supported by bun.

levinuncu commented 1 year ago

Im not using this repo but build something similiar and for me it worked putting the .env file next to the index.ts where createClient is called.

arjunindia commented 1 year ago

BTW, All issues for libsql with bun is likely fixed (atleast for me) after this: https://github.com/libsql/libsql-js/commit/39c8ac802093282718459140ab3562baf91f183c image

ethanniser commented 1 year ago

a ton of things have improved in recent versions of the libsql stuff feel free to reopen if you have a problem