Missing symbols when packaging electron-based app with native deps

this package can be built now.
But a symbol, _ZN2v89Exception9TypeErrorENS_5LocalINS_6StringEEE, unmangled as v8::Exception::TypeError(Local<String>), cannot be found at runtime due to a native deps located at /nix/store/...-cl-electron-server-0.0.1/lib/node_modules/cl-electron-server/node_modules/synchronous-socket/build/Release/SynchronousSocket.node.

These symbols can be found in buildtime, but failed in runtime.

What do I miss?
I think I should pass the runtime electron when building as well. But how?

Probably you need a specific Electron version.

I don’t really understand what you mean by “failed at runtime”, symbols are usually resolved at link time and set up properly. Can you share the command used and the full error message?

If npm_config_nodedir is set (it is, when using buildNpmPackage, maybe in other cases too), it will use the specified directory’s header files when compiling. You may be able to use unpack the electron.headers derivation and set npm_config_nodedir to point to the unpacked location.

There are currently no examples of this is nixpkgs, but I have a pending PR that does this (search for rstudio in nixpkgs PRs).

Not 100% if it fixes your problem, but the problem is the same.

1 Like
  1. clone my nixpkgs and check to that branch
  2. nix build ‘.#nyxt
  3. ./result/bin/nyxt -I (-I is for no config file)
  4. Then it print the following erros

Nyxt version 4.0.0-pre-release-1
[23:13:39] Source location: #P"/nix/store/snjkivxxx44gnxhkmnz4whyl9rlrzw2q-nyxt-4.0.0-pre-release-1/share/nyxt/"
[23:13:39] Listening to socket: #P"/run/user/1000/nyxt/nyxt.socket"
App threw an error during load
Error: /nix/store/qkdaf0j66sr5dfb57pn58l4l5ks643g2-cl-electron-server-0.0.1/lib/node_modules/cl-electron-server/node_modules/synchronous-socket/build/Release/SynchronousSocket.node: undefined symbol: _ZN2v89Exception9TypeErrorENS_5LocalINS_6StringEEE
at process.func [as dlopen] (node:electron/js2c/node_init:2:2559)
at Module._extensions…node (node:internal/modules/cjs/loader:1602:18)
at Object.func [as .node] (node:electron/js2c/node_init:2:2559)
at Module.load (node:internal/modules/cjs/loader:1295:32)
at Module._load (node:internal/modules/cjs/loader:1111:12)
at c._load (node:electron/js2c/node_init:2:16955)
at Module.require (node:internal/modules/cjs/loader:1318:19)
at require (node:internal/modules/helpers:179:18)
at bindings (/nix/store/qkdaf0j66sr5dfb57pn58l4l5ks643g2-cl-electron-server-0.0.1/lib/node_modules/cl-electron-server/node_modules/bindings/bindings.js:112:48)
at Object. (/nix/store/qkdaf0j66sr5dfb57pn58l4l5ks643g2-cl-electron-server-0.0.1/lib/node_modules/cl-electron-server/node_modules/synchronous-socket/index.js:1:44)
A JavaScript error occurred in the main process
Uncaught Exception:
Error: /nix/store/qkdaf0j66sr5dfb57pn58l4l5ks643g2-cl-electron-server-0.0.1/lib/node_modules/cl-electron-server/node_modules/synchronous-socket/build/Release/SynchronousSocket.node: undefined symbol: _ZN2v89Exception9TypeErrorENS_5LocalINS_6StringEEE
at process.func [as dlopen] (node:electron/js2c/node_init:2:2559)
at Module._extensions…node (node:internal/modules/cjs/loader:1602:18)
at Object.func [as .node] (node:electron/js2c/node_init:2:2559)
at Module.load (node:internal/modules/cjs/loader:1295:32)
at Module._load (node:internal/modules/cjs/loader:1111:12)
at c._load (node:electron/js2c/node_init:2:16955)
at Module.require (node:internal/modules/cjs/loader:1318:19)
at require (node:internal/modules/helpers:179:18)
at bindings (/nix/store/qkdaf0j66sr5dfb57pn58l4l5ks643g2-cl-electron-server-0.0.1/lib/node_modules/cl-electron-server/node_modules/bindings/bindings.js:112:48)
at Object.<anonymo

FliegendeWurst via NixOS Discourse discourse@discourse.nixos.org writes:

Thanks! Would you like to share your pr link or id?

Toma via NixOS Discourse discourse@discourse.nixos.org writes:

This was the PR I mentioned: rstudio: build as electron app, add darwin support by TomaSajt · Pull Request #362637 · NixOS/nixpkgs · GitHub

(The comment about electron-bin is outdated, forgot to remove it.)