aur icon indicating copy to clipboard operation
aur copied to clipboard

[Ezra bible app] error while building sqlite3 module

Open sweenu opened this issue 2 years ago • 16 comments

Hello, thanks for the aur package. It does not work however for me right now, failing with these errors:

/ezra-bible-app/src/ezra-bible-app-1.0.0/node_modules/sqlite3/node_modules/node-addon-api/napi-inl.h: In member function ‘bool Napi::Object::Freeze()’:
/ezra-bible-app/src/ezra-bible-app-1.0.0/node_modules/sqlite3/node_modules/node-addon-api/napi-inl.h:1393:24: error: ‘napi_object_freeze’ was not declared in this scope; did you mean ‘napi_object_expected’?
 1393 |   napi_status status = napi_object_freeze(_env, _value);
      |                        ^~~~~~~~~~~~~~~~~~
      |                        napi_object_expected
/ezra-bible-app/src/ezra-bible-app-1.0.0/node_modules/sqlite3/node_modules/node-addon-api/napi-inl.h: In member function ‘bool Napi::Object::Seal()’:
/ezra-bible-app/src/ezra-bible-app-1.0.0/node_modules/sqlite3/node_modules/node-addon-api/napi-inl.h:1399:24: error: ‘napi_object_seal’ was not declared in this scope; did you mean ‘napi_object’?
 1399 |   napi_status status = napi_object_seal(_env, _value);
      |                        ^~~~~~~~~~~~~~~~
      |                        napi_object
⠙ Building module: sqlite3, Completed: 0make: *** [node_sqlite3.target.mk:140: Release/obj.target/node_sqlite3/src/backup.o] Error 1
make: Leaving directory '/ezra-bible-app/src/ezra-bible-app-1.0.0/node_modules/sqlite3/build'
✖ Rebuild Failed

An unhandled error occurred inside electron-rebuild
node-gyp failed to rebuild '/ezra-bible-app/src/ezra-bible-app-1.0.0/node_modules/sqlite3'.
Error: `make` failed with exit code: 2

Error: node-gyp failed to rebuild '/ezra-bible-app/src/ezra-bible-app-1.0.0/node_modules/sqlite3'.
Error: `make` failed with exit code: 2

    at ModuleRebuilder.rebuildNodeGypModule (/ezra-bible-app/src/ezra-bible-app-1.0.0/node_modules/electron-rebuild/lib/src/module-rebuilder.js:193:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Rebuilder.rebuildModuleAt (/ezra-bible-app/src/ezra-bible-app-1.0.0/node_modules/electron-rebuild/lib/src/rebuild.js:190:9)
    at async Rebuilder.rebuild (/ezra-bible-app/src/ezra-bible-app-1.0.0/node_modules/electron-rebuild/lib/src/rebuild.js:152:17)
    at async /ezra-bible-app/src/ezra-bible-app-1.0.0/node_modules/electron-rebuild/lib/src/cli.js:146:9

I have the latest versions of electron (13.2.2) and nodejs (v16.8.0), this might be the problem I suppose.

sweenu avatar Aug 31 '21 07:08 sweenu

Yes, Electron updates broken this package. I've made several attempts to fix it and always come up short. I see today that 1.2.0 is out, I'll take another stab at getting it up to date. Thanks for the report.

alerque avatar Aug 31 '21 08:08 alerque

I was able to have something that compiles when adding this in the PKGBUILD before the npm install: sed -i 's/"sqlite3": "^5.0.0",/"sqlite3": "5.0.0",/' package.json However, when I launch the application, it forever stays on the loading page. I tried running the prebuilt package you have on your server and I have the same problem.

The error I get in the console is:

Uncaught ReferenceError: require is not defined
    at ezra_init.js:33

sweenu avatar Aug 31 '21 09:08 sweenu

I just had a pass at this and this is an absolute fiasco. Probably the best thing we could do for now is setup a -bin package variant to install some upstream built variant complete with a bundled version of Electron and everything else. Getting a source build to work properly is going to take some more work, it's just so scrambled...

alerque avatar Sep 01 '21 12:09 alerque

Yeah, it would be way easier indeed. Electron packages are apparently famously hard to package. I have no experience in nodejs let alone electron, but I can try to make a PR upstream building a binary in the CI. Thanks for taking the time to look into it!

sweenu avatar Sep 01 '21 13:09 sweenu

I just tried setting up a binary package (now at ezra-bible-app-bin) but it doesn't work because the latest Fedora build at least is linked against a version of ICU older than what Arch Linux has. The next thing to do is probably experiment with the other possible sources (Debian builds perhaps) and see if we can find one that is a match for the various libraries on Arch. Baring that we're back to trying to figure out a source build. Not impossible just a wrestling match.

alerque avatar Sep 01 '21 14:09 alerque

I mentioned this sqlite3 > 5.0.0 oddity in an upstream issue https://github.com/ezra-bible-app/ezra-bible-app/issues/436. Also see https://github.com/ezra-bible-app/ezra-bible-app/issues/23 about upstream embedding sqlite3 in the first place.

alerque avatar Sep 01 '21 14:09 alerque

@Sweenu I've applied your little trick to lock down the sqlite3 version and get a build ... but it's broken for me in the same way you describe at runtime. I just have a dotty spinner.

alerque avatar Sep 01 '21 14:09 alerque

The error I get in the console is:

Uncaught ReferenceError: require is not defined
    at ezra_init.js:33

This seems to be caused by changes in newer Electron versions. See https://github.com/electron/electron-quick-start/issues/463.

I just created an issue to plan bumping Electron in Ezra Bible App to a newer version. See https://github.com/ezra-bible-app/ezra-bible-app/issues/437

tobias-klein avatar Sep 01 '21 18:09 tobias-klein

Note that https://github.com/ezra-bible-app/ezra-bible-app/issues/437 is done now.

tobias-klein avatar Sep 02 '21 06:09 tobias-klein

Thanks, that's progress. With that in place the ezra-bible-app-git package (using the VCS package version to test things in between releases) now builds and installs just fine.

We're still hung up on whatever the runtime issue(s) are that make it hang with a spinner on launch. From the console output I see:

$ ezra-bible-app
Using settings file /home/caleb/.config/ezra-bible-app/config.json
Detected old InstallMgr directory installMgr.
Deleting previously used InstallMgr dir!
Using default database dir /home/caleb/.config/ezra-bible-app for database access!
Initializing database at /home/caleb/.config/ezra-bible-app
Database not yet existing in user directory!
Copying database from previously used application directory /home/caleb/.config/ezra-project/ezra.sqlite.
Error occurred in handler for 'initIpc': Error: Please install sqlite3 package manually
    at ConnectionManager._loadDialectModule (/usr/lib/ezra-bible-app/resources/app.asar/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:88:15)
    at new ConnectionManager (/usr/lib/ezra-bible-app/resources/app.asar/node_modules/sequelize/lib/dialects/sqlite/connection-manager.js:22:21)
    at new SqliteDialect (/usr/lib/ezra-bible-app/resources/app.asar/node_modules/sequelize/lib/dialects/sqlite/index.js:14:30)
    at new Sequelize (/usr/lib/ezra-bible-app/resources/app.asar/node_modules/sequelize/lib/sequelize.js:334:20)
    at DbHelper.getSequelize (/usr/lib/ezra-bible-app/resources/app.asar/app/backend/database/db_helper.js:114:21)
    at DbHelper.migrateDatabase (/usr/lib/ezra-bible-app/resources/app.asar/app/backend/database/db_helper.js:119:26)
    at DbHelper.initDatabase (/usr/lib/ezra-bible-app/resources/app.asar/app/backend/database/db_helper.js:42:16)
    at IpcDbHandler.initDatabase (/usr/lib/ezra-bible-app/resources/app.asar/app/backend/ipc/ipc_db_handler.js:52:20)
    at IPC.initDatabase (/usr/lib/ezra-bible-app/resources/app.asar/app/backend/ipc/ipc.js:85:24)
    at IPC.init (/usr/lib/ezra-bible-app/resources/app.asar/app/backend/ipc/ipc.js:78:20)
    at /usr/lib/ezra-bible-app/resources/app.asar/main.js:121:17
    at electron/js2c/browser_init.js:197:579
    at Object.<anonymous> (electron/js2c/browser_init.js:161:9782)
    at Object.emit (events.js:315:20)

Note this is without any hackery to change the sqlite3 version or replace it with a system-installed library. A system sqlite3 binary is available, but nothing has been done in the Ezra packaging to remove the bundled one it's supposed to use.

alerque avatar Sep 02 '21 08:09 alerque

I believe the runtime issues are caused by some sort of incompatibility between the compiled nodejs module and the Electron binary. I have seen this before. Will have a look.

tobias-klein avatar Sep 04 '21 07:09 tobias-klein

I tried to get a local environment with Arch Linux running (first Docker, then VirtualBox) - but to no avail.

tobias-klein avatar Sep 06 '21 06:09 tobias-klein

We're still hung up on whatever the runtime issue(s) are that make it hang with a spinner on launch. From the console output I see:

$ ezra-bible-app
Using settings file /home/caleb/.config/ezra-bible-app/config.json
Detected old InstallMgr directory installMgr.
Deleting previously used InstallMgr dir!
Using default database dir /home/caleb/.config/ezra-bible-app for database access!
Initializing database at /home/caleb/.config/ezra-bible-app
Database not yet existing in user directory!
Copying database from previously used application directory /home/caleb/.config/ezra-project/ezra.sqlite.
Error occurred in handler for 'initIpc': Error: Please install sqlite3 package manually
    at ConnectionManager._loadDialectModule (/usr/lib/ezra-bible-app/resources/app.asar/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:88:15)
    at new ConnectionManager (/usr/lib/ezra-bible-app/resources/app.asar/node_modules/sequelize/lib/dialects/sqlite/connection-manager.js:22:21)
    at new SqliteDialect (/usr/lib/ezra-bible-app/resources/app.asar/node_modules/sequelize/lib/dialects/sqlite/index.js:14:30)
    at new Sequelize (/usr/lib/ezra-bible-app/resources/app.asar/node_modules/sequelize/lib/sequelize.js:334:20)
    at DbHelper.getSequelize (/usr/lib/ezra-bible-app/resources/app.asar/app/backend/database/db_helper.js:114:21)
    at DbHelper.migrateDatabase (/usr/lib/ezra-bible-app/resources/app.asar/app/backend/database/db_helper.js:119:26)
    at DbHelper.initDatabase (/usr/lib/ezra-bible-app/resources/app.asar/app/backend/database/db_helper.js:42:16)
    at IpcDbHandler.initDatabase (/usr/lib/ezra-bible-app/resources/app.asar/app/backend/ipc/ipc_db_handler.js:52:20)
    at IPC.initDatabase (/usr/lib/ezra-bible-app/resources/app.asar/app/backend/ipc/ipc.js:85:24)
    at IPC.init (/usr/lib/ezra-bible-app/resources/app.asar/app/backend/ipc/ipc.js:78:20)
    at /usr/lib/ezra-bible-app/resources/app.asar/main.js:121:17
    at electron/js2c/browser_init.js:197:579
    at Object.<anonymous> (electron/js2c/browser_init.js:161:9782)
    at Object.emit (events.js:315:20)

Note this is without any hackery to change the sqlite3 version or replace it with a system-installed library. A system sqlite3 binary is available, but nothing has been done in the Ezra packaging to remove the bundled one it's supposed to use.

@alerque I have also seen these runtime issues on Windows. This happens when there is a mismatch between the runtime the sqlite module was built against and the runtime used to load it.

This is the npm install command I have used for the Windows build script to ensure that we're building against the right Electron version: npm install [email protected] --build-from-source --runtime=electron --target=13.2.3 --dist-url=https://electronjs.org/headers

Of course you may have to adjust the Electron version based on what's used in your case. Can you give it another try with this?

tobias-klein avatar Oct 31 '21 11:10 tobias-klein

@alerque Any feedback here?

tobias-klein avatar Nov 11 '21 20:11 tobias-klein

I'm on the road right now and away from my usual build systems and have very limited time for FOSS until I stop traveling in December.

alerque avatar Nov 23 '21 21:11 alerque

@alerque Any news on this? :)

tobias-klein avatar Oct 28 '22 16:10 tobias-klein