Closed otekdo closed 1 year ago
You need to install better-sqlite3
and run it's build-debug
script like this.
bun install --dev better-sqlite3
bun run --cwd node_modules/better-sqlite3 build-debug
@hanssonduck Second command did not work First command
bun install --dev better-sqlite3
bun add v0.8.1
installed better-sqlite3@8.6.0
[547.00ms] done
Second command
bun run --cwd node_modules/better-sqlite3 build-debug
$ node-gyp rebuild --debug
/usr/bin/bash: line 1: node-gyp: command not found
error: script "build-debug" exited with code 127
I also have NodeJs installed,
v.18.17.1
@hanssonduck Second command did not work First command
bun install --dev better-sqlite3 bun add v0.8.1 installed better-sqlite3@8.6.0 [547.00ms] done
Second command
bun run --cwd node_modules/better-sqlite3 build-debug $ node-gyp rebuild --debug /usr/bin/bash: line 1: node-gyp: command not found error: script "build-debug" exited with code 127
I also have NodeJs installed,
v.18.17.1
Install it with bun add --global node-gyp
and try again.
Sharing progress Build debug results
bun run --cwd node_modules/better-sqlite3 build-debug
$ node-gyp rebuild --debug
gyp info it worked if it ends with ok
gyp info using node-gyp@9.4.0
gyp info using node@18.17.1 | linux | x64
gyp info find Python using Python version 3.10.12 found at "/usr/bin/python3"
gyp http GET https://nodejs.org/download/release/v18.17.1/node-v18.17.1-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v18.17.1/node-v18.17.1-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v18.17.1/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v18.17.1/SHASUMS256.txt
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args '/home/nexus/.bun/install/global/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/home/nexus/Documents/apps/bun-drizzle-sqlite/node_modules/better-sqlite3/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/nexus/.bun/install/global/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/nexus/.cache/node-gyp/18.17.1/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/home/nexus/.cache/node-gyp/18.17.1',
gyp info spawn args '-Dnode_gyp_dir=/home/nexus/.bun/install/global/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/home/nexus/.cache/node-gyp/18.17.1/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/home/nexus/Documents/apps/bun-drizzle-sqlite/node_modules/better-sqlite3',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Debug', '-C', 'build' ]
make: Entering directory '/home/nexus/Documents/apps/bun-drizzle-sqlite/node_modules/better-sqlite3/build'
TOUCH ba23eeee118cd63e16015df367567cb043fed872.intermediate
ACTION deps_sqlite3_gyp_locate_sqlite3_target_copy_builtin_sqlite3 ba23eeee118cd63e16015df367567cb043fed872.intermediate
TOUCH Debug/obj.target/deps/locate_sqlite3.stamp
CC(target) Debug/obj.target/sqlite3/gen/sqlite3/sqlite3.o
rm -f Debug/obj.target/deps/sqlite3.a Debug/obj.target/deps/sqlite3.a.ar-file-list; mkdir -p `dirname Debug/obj.target/deps/sqlite3.a`
ar crs Debug/obj.target/deps/sqlite3.a @Debug/obj.target/deps/sqlite3.a.ar-file-list
COPY Debug/sqlite3.a
CXX(target) Debug/obj.target/better_sqlite3/src/better_sqlite3.o
In file included from ./src/better_sqlite3.lzz:11,
from ../src/better_sqlite3.cpp:4:
/home/nexus/.cache/node-gyp/18.17.1/include/node/node.h:1034:7: warning: cast between incompatible function types from ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Context>)’ to ‘node::addon_context_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Context>, void*)’} [-Wcast-function-type]
1034 | (node::addon_context_register_func) (regfunc), \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/nexus/.cache/node-gyp/18.17.1/include/node/node.h:1052:3: note: in expansion of macro ‘NODE_MODULE_CONTEXT_AWARE_X’
1052 | NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, NULL, 0)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/nexus/.cache/node-gyp/18.17.1/include/node/node.h:1083:3: note: in expansion of macro ‘NODE_MODULE_CONTEXT_AWARE’
1083 | NODE_MODULE_CONTEXT_AWARE(NODE_GYP_MODULE_NAME, \
| ^~~~~~~~~~~~~~~~~~~~~~~~~
./src/better_sqlite3.lzz:67:1: note: in expansion of macro ‘NODE_MODULE_INIT’
./src/util/data.lzz: In function ‘v8::Local<v8::Value> Data::GetValueJS(v8::Isolate*, sqlite3_stmt*, int, bool)’:
./src/util/data.lzz:73:92: warning: this statement may fall through [-Wimplicit-fallthrough=]
./src/util/data.lzz:73:197: note: here
./src/util/data.lzz: In function ‘v8::Local<v8::Value> Data::GetValueJS(v8::Isolate*, sqlite3_value*, bool)’:
./src/util/data.lzz:77:81: warning: this statement may fall through [-Wimplicit-fallthrough=]
./src/util/data.lzz:77:175: note: here
SOLINK_MODULE(target) Debug/obj.target/better_sqlite3.node
COPY Debug/better_sqlite3.node
CC(target) Debug/obj.target/test_extension/deps/test_extension.o
SOLINK_MODULE(target) Debug/obj.target/test_extension.node
COPY Debug/test_extension.node
rm ba23eeee118cd63e16015df367567cb043fed872.intermediate
make: Leaving directory '/home/nexus/Documents/apps/bun-drizzle-sqlite/node_modules/better-sqlite3/build'
gyp info ok
Great, it worked! @hanssonduck a lot of thanks!
bun run push
$ bun drizzle-kit push:sqlite
No config path provided, using default path
Reading config file '/home/nexus/Documents/apps/bun-drizzle-sqlite/drizzle.config.ts'
drizzle-kit: v0.19.13
drizzle-orm: v0.28.5
[✓] Changes applied
Looks like the setup documentation on drizzle should be updated
https://orm.drizzle.team/docs/installation-and-db-connection/sqlite/bun
That is the page i was reading/following
I was not aware that i needed to run the command @hanssonduck recommended, by the time i will update my README.md file on my repo
Looks like the setup documentation on drizzle should be updated https://orm.drizzle.team/docs/installation-and-db-connection/sqlite/bun That is the page i was
reading/following
I was not aware that i needed to run the command @hanssonduck recommended, by the time i will update my README.md file on my repo
This should be fixed when Drizzle Kit drop Node as a dependency.
I found the solution to my problem, but the documentation is not updated yet.
Hi guys - I found a more elegant solution to this problem
better-sqlite3 wants to run post-install scripts which are not trusted by Bun by default.
As per Bun's documentation you need to add the following line to your package.json
"trustedDependencies": [ "better-sqlite3" ],
You can then delete your node_modules folder and bun.lockb files Re-install with bun install and you are good to go!
Here is the link to the docs https://bun.sh/guides/install/trusted
When using Bun, you don't need an SQLite library such as better-sqlite3 anymore. So requiring better-sqlite3 just to run migrations seems wrong.
https://bun.sh/guides/ecosystem/drizzle has a nicer workaround for this issue.
I vote to re-open this issue. And would suggest allowing 'bun:sqlite' as a possible value for the dialect setting in drizzle.config.ts, then using that by drizzle-kit to figure out what implementation to use.
What version of
drizzle-orm
are you using?0.28.5
What version of
drizzle-kit
are you using?0.19.13
Describe the Bug
It does not migrate the schema to the
database file
Repository Link: https://github.com/otekdo/bunjs-drizzle-sqlite
generate
command workspush
command does not worksIt does not matter which driver is set on drizzle config file, issue still happens
libsql
orbetter-sqlite
Expected behavior
Generate the
db
file with its table created and then show empty row of users when running Bun web serverEnvironment & setup
Repository: https://github.com/otekdo/bunjs-drizzle-sqlite Bun: v0.8.1 drizzle-kit: v0.19.13 drizzle-orm: v0.28.5