Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined symbol on node 20 with nix #1295

Open
irisjae opened this issue Nov 23, 2024 · 4 comments
Open

Undefined symbol on node 20 with nix #1295

irisjae opened this issue Nov 23, 2024 · 4 comments

Comments

@irisjae
Copy link

irisjae commented Nov 23, 2024

I was trying this library out in the REPL as it looked promising, but I seem to have run into some problem with the prebuilt stuff. For what it's worth, while better-sqlite3 doesn't work, sqlite3 seems to work for me.

I'm on node v20.5.0 packaged with Nix (using node2nix), and the machine is a NixOS VM on M1 (aarch64).

> var db = require('better-sqlite3')('foobar.db')                                                                                                                                                            
Uncaught:                                                                                                                                                                                                    
Error: /nix/store/g9168fk4d0ckk036xxz2ca3kq3ay7wdy-node-dependencies-custom-node-modules/lib/node_modules/bettersqlite3/build/Release/better_sqlite3.node: undefined symbol: _ZN2v88internal20CanHaveInternalFieldEi
    at Module._extensions..node (node:internal/modules/cjs/loader:1319:18)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:119:18)
    at bindings (/nix/store/g9168fk4d0ckk036xxz2ca3kq3ay7wdy-node-dependencies-custom-node-modules/lib/node_modules/bindings/bindings.js:112:48)
    at new Database (/nix/store/g9168fk4d0ckk036xxz2ca3kq3ay7wdy-node-dependencies-custom-node-modules/lib/node_modules/better-sqlite3/lib/database.js:48:64)
    at Database (/nix/store/g9168fk4d0ckk036xxz2ca3kq3ay7wdy-node-dependencies-custom-node-modules/lib/node_modules/better-sqlite3/lib/database.js:11:10) {
  code: 'ERR_DLOPEN_FAILED'
}
@neoxpert
Copy link
Contributor

Which version of glibc is installed on the system?

@irisjae
Copy link
Author

irisjae commented Nov 24, 2024

ldd --version yields ldd (GNU libc) 2.40

@neoxpert
Copy link
Contributor

Well, at least that should fit. _ZN2v88internal20CanHaveInternalFieldEi hints to some mismatch (missing entry point) within libs NodeJS is using / provided with. While sqlite3 utilizes the N-Api, better-sqlite3 uses the the v8 interface which has different requirements to the runtime. As with Alpine, I guess that the NodeJS build using node2nix is missing some dependencies or using outdated versions.

Have you tried setting up some build environment on NixOS to compile the native module for better-sqlite3?

@irisjae
Copy link
Author

irisjae commented Nov 26, 2024

In the meantime I've resorted to node:sqlite (I really needed the sync api). Let me try the build sometime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants