TryGhost / node-sqlite3

SQLite3 bindings for Node.js
BSD 3-Clause "New" or "Revised" License
6.18k stars 812 forks source link

ci: macos external sqlite3 disables extension loading #1509

Open kewde opened 2 years ago

kewde commented 2 years ago

The default MacOS external sqlite3 installed through homebrew does not support extension loading and errors on compilation:

../src/database.cc:680:5: error: use of undeclared identifier 'sqlite3_enable_load_extension'
    sqlite3_enable_load_extension(baton->db->_handle, 1);
    ^
../src/database.cc:683:21: error: use of undeclared identifier 'sqlite3_load_extension'
    baton->status = sqlite3_load_extension(
                    ^
../src/database.cc:690:5: error: use of undeclared identifier 'sqlite3_enable_load_extension'
    sqlite3_enable_load_extension(baton->db->_handle, 0);
    ^
4 warnings and 3 errors generated.
make: *** [Release/obj.target/node_sqlite3/src/database.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
vladfaust commented 2 years ago

Can't install the package locally on my M1 due to the same error. Any workarounds?

kewde commented 2 years ago

@vladfaust You should only have this issue if you're building like this:

npm install --build-from-source --sqlite=/usr/local/opt/sqlite/

By default it should attempt to build like this:

npm install --build-from-source

You can attempt removing the extension code though as a workaround. Attempt commenting out the code in https://github.com/TryGhost/node-sqlite3/blob/master/src/database.cc#L677-L696