emdash icon indicating copy to clipboard operation
emdash copied to clipboard

[bug]: node_sqlite3.node requires GLIBC_2.38, breaking Ubuntu 22.04 and other older distros

Open 6uimorais opened this issue 8 months ago โ€ข 10 comments

Bug Description

The prebuilt node_sqlite3.node binary shipped in Emdash v0.4.42 (.deb and AppImage) requires GLIBC_2.38, which is not available on Ubuntu 22.04 LTS (ships GLIBC 2.35). This prevents opening any project โ€” the app launches but displays:

Error: /lib/x86_64-linux-gnu/libm.so.6: version 'GLIBC_2.38' not found (required by ...node_sqlite3.node)

This contradicts the documented requirement of GLIBC 2.28+ / Ubuntu 20.04+.

Steps to Reproduce

  1. Install Emdash v0.4.42 via emdash-amd64.deb on Ubuntu 22.04 LTS
  2. Launch Emdash
  3. Try to open or create any project

Actual vs Expected Behavior

Actual: Dialog with error /lib/x86_64-linux-gnu/libm.so.6: version 'GLIBC_2.38' not found (required by .../node_sqlite3.node). No project can be opened.

Expected: Project opens normally, as it did on earlier Emdash versions and as the documented system requirements suggest.

Root Cause Analysis

The sole incompatible symbol is fmod@GLIBC_2.38 in node_sqlite3.node (sqlite3 v5.1.7):

$ objdump -T /opt/Emdash/resources/app.asar.unpacked/node_modules/sqlite3/build/Release/node_sqlite3.node | grep GLIBC_2.38
0000000000000000      DF *UND*  0000000000000000 (GLIBC_2.38) fmod

Both copies of the binary are affected:

  • resources/app.asar.unpacked/node_modules/sqlite3/build/Release/node_sqlite3.node
  • resources/app.asar.unpacked/node_modules/sqlite3/bin/linux-x64-123/sqlite3.node

The AppImage ships the same binary (identical MD5), so it has the same issue.

This is a known upstream pattern: when node-sqlite3 prebuilt binaries are compiled on Ubuntu 24.04+ (GLIBC โ‰ฅ 2.38), the linker binds fmod() to the GLIBC_2.38 symbol version. The node-sqlite3 project fixed this previously by building on Ubuntu 20.04. It's likely that the Emdash CI upgraded its build image (possibly when electron-rebuild was added in v0.4.17), reintroducing the issue.

Workaround

Rebuilding node_sqlite3.node locally from source resolves the issue:

mkdir /tmp/sqlite3-fix && cd /tmp/sqlite3-fix
npm init -y
npm install [email protected] --build-from-source
sudo cp node_modules/sqlite3/build/Release/node_sqlite3.node \
  /opt/Emdash/resources/app.asar.unpacked/node_modules/sqlite3/build/Release/node_sqlite3.node
sudo cp node_modules/sqlite3/build/Release/node_sqlite3.node \
  /opt/Emdash/resources/app.asar.unpacked/node_modules/sqlite3/bin/linux-x64-123/sqlite3.node

Suggested Fix

Build the Linux release on Ubuntu 20.04 or 22.04 (or use --target-libc / a container with an older GLIBC) to ensure the prebuilt native modules are compatible with the documented minimum requirement (GLIBC 2.28).

emdash Version

0.4.42

Operating System

Ubuntu 22.04.5 LTS, kernel 6.8.0-106-generic, GLIBC 2.35

Additional Context

  • Electron version: 30.5.1
  • sqlite3 module version: 5.1.7
  • The fmod function exists in GLIBC since version 2.2.5 โ€” only the symbol version tag differs, so the fix is purely a build-environment issue, not a code change.
  • This likely affects any Linux distro with GLIBC < 2.38 (Debian 12, Fedora 38, RHEL 9, etc.).

6uimorais avatar Mar 28 '26 15:03 6uimorais

Same problem on Almalinux as well, however, the workaround doesn't appear to work on Almalinux either. I get an error when doing the npm install.

npm error make: cc: No such file or directory
npm error make: *** [../node-addon-api/nothing.target.mk:104: Release/obj.target/nothing/../node-addon-api/nothing.o] Error 127
npm error gyp ERR! build error 
npm error gyp ERR! stack Error: `make` failed with exit code: 2
npm error gyp ERR! stack     at ChildProcess.onExit (/tmp/sqlite3-fix/node_modules/node-gyp/lib/build.js:194:23)
npm error gyp ERR! stack     at ChildProcess.emit (node:events:519:28)
npm error gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:294:12)
npm error gyp ERR! System Linux 5.14.0-611.16.1.el9_7.x86_64

Edit: Workaround on Almalinux found:

sudo dnf groupinstall "Development Tools" -y
sudo dnf install python3 -y
mkdir /tmp/sqlite3-fix && cd /tmp/sqlite3-fix
npm install sqlite3 --build-from-source --python=/usr/bin/python3

However, on Almalinux you have to use the AppImage download and not the deb, which seems Emdash just runs from the AppImage file itself and does store anything into /opt/Emdash, so the cp commands don't work since /opt/Emdash doesn't exist....

The solution is to use --appimage-extract. Run this where you downloaded the Emdash AppImage file:

./emdash-x86_64.AppImage --appimage-extract

This creates a squashfs-root directory which contains the application source files in the same directory as the AppImage. Then you can copy the sqlite stuff into this directory. Run this from the directory where the AppImage file is:

export DIRECTORY=$(pwd)
sudo cp /tmp/sqlite3-fix/node_modules/sqlite3/build/Release/node_sqlite3.node $DIRECTORY/squashfs-root/resources/app.asar.unpacked/node_modules/sqlite3/build/Release/node_sqlite3.node
sudo cp /tmp/sqlite3-fix/node_modules/sqlite3/build/Release/node_sqlite3.node $DIRECTORY/squashfs-root/resources/app.asar.unpacked/node_modules/sqlite3/bin/linux-x64-123/sqlite3.node

And then to run Emdash, just ensure that you run Emdash from the squashfs-root folder with:

./squashfs-root/AppRun

You could even alias emdash=$(pwd)/squashfs-root/AppRun or something to be able to run it from anywhere

QuinnBast avatar Apr 16 '26 18:04 QuinnBast

Hi @6uimorais @QuinnBast, This exact v0.4.42 sqlite3/node_sqlite3.node failure is not the same in v1 because the app database now uses better-sqlite3 and release builds rebuild native modules. However, the underlying Linux GLIBC compatibility risk still applies to v1 native modules unless release builds are pinned to an older glibc environment or verified against the documented minimum. Keeping this open/valid as a packaging compatibility issue, but the failing module to verify for v1 is likely better_sqlite3.node or another rebuilt native module rather than node_sqlite3.node.

arnestrickmann avatar May 01 '26 09:05 arnestrickmann

Hi @6uimorais @QuinnBast, This exact v0.4.42 sqlite3/node_sqlite3.node failure is not the same in v1 because the app database now uses better-sqlite3 and release builds rebuild native modules. However, the underlying Linux GLIBC compatibility risk still applies to v1 native modules unless release builds are pinned to an older glibc environment or verified against the documented minimum. Keeping this open/valid as a packaging compatibility issue, but the failing module to verify for v1 is likely better_sqlite3.node or another rebuilt native module rather than node_sqlite3.node.

@arnestrickmann

I didn't follow.

i just saw this tool and attempted to install it (deb and appimage), and hit this GLIBC issue on ubuntu 22.04. There was no mention of a required OS version or glibc anywhere in documentation.

the app crashed immediately with: 'GLIBC_2.38' not found

since this issue was closed (https://github.com/generalaction/emdash/issues/1619#event-25067096289), should it be known there is a required minimum GLIBC/ubuntu version?

for reference, my errors on latest v1.1.10:

deb
emdash
A JavaScript error occurred in the main process
Uncaught Exception:
Error: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.38' not found (required by /opt/Emdash/resources/app.asar.unpacked/node_modules/better-sqlite3/build/Release/better_sqlite3.node)
    at process.func [as dlopen] (node:electron/js2c/node_init:2:2617)
    at Module._extensions..node (node:internal/modules/cjs/loader:1980:18)
    at Object.func [as .node] (node:electron/js2c/node_init:2:2844)
    at Module.load (node:internal/modules/cjs/loader:1540:32)
    at Module._load (node:internal/modules/cjs/loader:1342:12)
    at c._load (node:electron/js2c/node_init:2:17999)
    at wrapModuleLoad (node:internal/modules/cjs/loader:262:19)
    at Module.require (node:internal/modules/cjs/loader:1563:12)
    at require (node:internal/modules/helpers:152:16)
    at bindings (/opt/Emdash/resources/app.asar/node_modules/bindings/bindings.js:112:48)
appimage
./emdash-x86_64.AppImage 
A JavaScript error occurred in the main process
Uncaught Exception:
Error: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.38' not found (required by /tmp/.mount_emdashQRls3r/resources/app.asar.unpacked/node_modules/better-sqlite3/build/Release/better_sqlite3.node)
    at process.func [as dlopen] (node:electron/js2c/node_init:2:2617)
    at Module._extensions..node (node:internal/modules/cjs/loader:1980:18)
    at Object.func [as .node] (node:electron/js2c/node_init:2:2844)
    at Module.load (node:internal/modules/cjs/loader:1540:32)
    at Module._load (node:internal/modules/cjs/loader:1342:12)
    at c._load (node:electron/js2c/node_init:2:17999)
    at wrapModuleLoad (node:internal/modules/cjs/loader:262:19)
    at Module.require (node:internal/modules/cjs/loader:1563:12)
    at require (node:internal/modules/helpers:152:16)
    at bindings (/tmp/.mount_emdashQRls3r/resources/app.asar/node_modules/bindings/bindings.js:112:48)
[21579:0509/142445.782301:ERROR:dbus/object_proxy.cc:573] Failed to call method: org.freedesktop.systemd1.Manager.StartTransientUnit: object_path= /org/freedesktop/systemd1: org.freedesktop.systemd1.UnitExists: Unit app-org.chromium.Chromium-21579.scope already exists

evdcush avatar May 09 '26 06:05 evdcush

Yeah, evdcush is correct, this doesn't appear to be fixed. I Had a coworker attempt to install the updated version of EmDash (I haven't tried it myself yet) and they also ran into this issue even with the updated version of EmDash

QuinnBast avatar May 21 '26 16:05 QuinnBast

I attempted to find a workaround to run 1.0 on Almalinux, and it took me like 1-2 hours to figure out but I finally got it working so that I can use 1.0. The major pain point is that better-sqlite requires being compiled against electron, and just doing npm install on better-sqlite doesn't work because the version of node on your machine cannot be the required "143" which is exclusively for electron 40.

So when you attempt the workaround above, you need to use electron-rebuild, otherwise you run into this error:

A JavaScript error occurred in the main process Uncaught Exception: Error: The module '/Downloads/emdash_v1/squashfs-root/resources/app.asar.unpacked/node_modules/> better-sqlite3/build/Release/better_sqlite3.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 115. This version of Node.js requires NODE_MODULE_VERSION 143. Please try re-compiling or re-installing

https://github.com/WiseLibs/better-sqlite3/issues/797

So follow the steps as before (I used node 23 as well as a precaution. Not sure if this was nessecary):

nvm install 23 && nvm use 23
mkdir /tmp/better-sqlite3-fix && cd /tmp/better-sqlite3-fix
npm init -y

Then you can download better-sqlite3, but you now also need to install electron-rebuild!

npm install better-sqlite3 --build-from-source
npm install --save-dev electron-rebuild

Then, you need to run electron-rebuild to rebuild the node dependencies as if they were installed for electron 40:

./node_modules/.bin/electron-rebuild -v 40.0.0

Now, finally, we can copy the new better-sqlite3 file into it's expected location in the AppImage as a replacement:

cp /tmp/better-sqlite3-fix/node_modules/better-sqlite3/build/Release/better_sqlite3.node ./squashfs-root/resources/app.asar.unpacked/node_modules/better-sqlite3/build/Release/better_sqlite3.node

This should definitely be re-opened, as EmDash just doesn't work at all on these distros. Almalinux 9 also isn't really an "older distro", it was released in 2022 which is fairly recent and is supported until 2027.

Also note, that if you are using this method, none of your existing Emdash tasks/conversations get saved and Emdash 1.0 starts completely empty

QuinnBast avatar May 22 '26 17:05 QuinnBast

Still reproduces on v1.1.38 โ€” seconding @QuinnBast's reopen request. This was closed as completed, but the Linux release builds still ship a better-sqlite3 native module compiled against glibc 2.38, so the app crashes on launch on any distro with an older glibc: Ubuntu 22.04 LTS / Pop!_OS 22.04 (glibc 2.35), Debian 12 (2.36), RHEL/Alma 9 (2.34), etc. โ€” all still-supported LTS releases.

The failing module changed from node_sqlite3.node (v0.4) to better_sqlite3.node (v1), which is probably why it looked fixed โ€” but the glibc floor is the same regression. Confirmed here on v1.1.38 (emdash_1.1.38_amd64.deb), Pop!_OS 22.04 (glibc 2.35):

Uncaught Exception:
Error: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.38' not found (required by /opt/Emdash/resources/app.asar.unpacked/node_modules/better-sqlite3/build/Release/better_sqlite3.node)
    at process.func [as dlopen] (node:electron/js2c/node_init:2:2617)
    ...
    at bindings (/opt/Emdash/resources/app.asar/node_modules/bindings/bindings.js:112:48)

Adding some diagnosis on top of the existing thread, since the fix here is on the packaging side, not the user side.

Electron 40 itself only needs glibc 2.31+, so the app binary is fine โ€” it's only the native modules rebuilt during release packaging that raise the floor. Max glibc symbol required by each bundled native module in the 1.1.38 deb:

Module Requires On glibc 2.35
better-sqlite3/build/Release/better_sqlite3.node GLIBC_2.38 โŒ crash on launch
better-sqlite3/bin/linux-x64-143/better-sqlite3.node GLIBC_2.38 โŒ
@parcel/watcher/build/Release/watcher.node GLIBC_2.38 โš ๏ธ unused โ€” the @parcel/watcher-linux-x64-glibc prebuild (GLIBC_2.14) resolves first
node-pty (both copies) GLIBC_2.34 โœ…

(Checked with strings <file>.node | grep -oE 'GLIBC_2\.[0-9]+' | sort -Vu | tail -1.)

Root cause: the release workflow rebuilds native modules from source on the CI runner, so the binaries inherit the runner's glibc. A runner image with glibc 2.38+ (e.g. ubuntu-24.04) produces artifacts that only run on 2.38+.

Suggested fixes (any one):

  1. Pin the Linux release job to ubuntu-22.04 runners (glibc 2.35), or build in a container with an older baseline โ€” the standard approach for portable Linux binaries.
  2. Skip the source rebuild for better-sqlite3 and ship its official prebuilt Electron binaries (built against an older baseline).
  3. Add a CI check on the packaged artifacts that fails if any .node requires a glibc newer than a documented minimum (the one-liner above works), so this can't silently regress again.

If a newer glibc floor is intentional, it'd help to document the minimum supported distro/glibc on the download page โ€” right now the failure mode is just an opaque crash dialog. Also worth noting the AppImage is not a workaround โ€” it bundles the same binaries and fails the same way.

Workaround is the same as @QuinnBast's above โ€” rebuild better-sqlite3 against Electron 40 and overwrite the bundled copies. A one-command variant that skips the separate electron-rebuild step (the npm_config_* vars build against the Electron headers directly, so it comes out as the Electron ABI, module version 143, in one go); verified on Pop!_OS 22.04, v1.1.38:

mkdir /tmp/bs3-fix && cd /tmp/bs3-fix && npm init -y
npm_config_runtime=electron npm_config_target=40.7.0 \
npm_config_disturl=https://electronjs.org/headers \
npm_config_build_from_source=true npm install [email protected]

D=/opt/Emdash/resources/app.asar.unpacked/node_modules/better-sqlite3
S=node_modules/better-sqlite3/build/Release/better_sqlite3.node
sudo cp "$S" "$D/build/Release/better_sqlite3.node"
sudo cp "$S" "$D/bin/linux-x64-143/better-sqlite3.node"

(Match npm_config_target to the bundled Electron: strings /opt/Emdash/emdash | grep -m1 -oE 'Electron/[0-9.]+'.)

onel0p3z avatar Jul 13 '26 20:07 onel0p3z

Hi @onel0p3z,

Sorry this was closed before the issue was fully resolved, and thanks for the detailed report, suggested fixes, and verification on v1.1.38. The additional diagnosis is very helpful.

Iโ€™ve reopened the issue so we can investigate the Linux release packaging and the proposed fixes. Weโ€™ll share an update here once we have more information or a fix is available. Thanks also for documenting the workaround and confirming that the AppImage is affected.

Arne

arnestrickmann avatar Jul 14 '26 21:07 arnestrickmann

@arnestrickmann thanks for reopening it and taking a look. Let me know if there's anything else I can help with!

onel0p3z avatar Jul 14 '26 22:07 onel0p3z

closing this as resolved

jschwxrz avatar Sep 01 '26 13:09 jschwxrz

Beautiful!! Works like a charm! Thank you!!

QuinnBast avatar Sep 02 '26 19:09 QuinnBast