Not possible to update or reinstall Trilium

:uk:/:us: Message template (english)

My YunoHost server

Hardware: VPS
YunoHost version: 11.2.8
I have access to my server : Through SSH | through the webadmin
If your request is related to an app, specify its name and version: Trilium Notes 0.61.15 - Last working version for me is 0.59.2

Description of my issue

Trilium update is running and seems to be successful, but when I call it up in the browser I get “Bad Gateway”.

I have also uninstalled Trilium in yunohost and then reinstalled it. The installation goes through and is supposedly successful. But when I call it up in the browser, I also get Bad Gateway.

Any ideas?

 DEBUG Dec 06 15:57:34 node[9418]:     at Module.load (node:internal/modules/cjs/loader:1091:32)
422586 DEBUG Dec 06 15:57:34 node[9418]:     at Module._load (node:internal/modules/cjs/loader:938:12)
422586 DEBUG Dec 06 15:57:34 node[9418]:     at Module.require (node:internal/modules/cjs/loader:1115:19)
422586 DEBUG Dec 06 15:57:34 node[9418]:     at require (node:internal/modules/helpers:130:18)
422586 DEBUG Dec 06 15:57:34 node[9418]:     at bindings (/var/www/trilium/node_modules/bindings/bindings.js:112:48)
422587 DEBUG Dec 06 15:57:34 node[9418]:     at Object.<anonymous> (/var/www/trilium/node_modules/better-sqlite3/lib/database.js:9:24)
422587 DEBUG Dec 06 15:57:34 node[9418]:     at Module._compile (node:internal/modules/cjs/loader:1241:14)
422587 DEBUG Dec 06 15:57:34 node[9418]:     at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
422587 DEBUG Dec 06 15:57:34 node[9418]:     at Module.load (node:internal/modules/cjs/loader:1091:32) {
422588 DEBUG Dec 06 15:57:34 node[9418]:   code: '\''ERR_DLOPEN_FAILED'\''
422588 DEBUG Dec 06 15:57:34 node[9418]: }
422588 DEBUG Dec 06 15:57:34 node[9418]: Node.js v20.7.0
422589 DEBUG Dec 06 15:57:34 systemd[1]: trilium.service: Main process exited, code=exited, status=1/FAILURE
422589 DEBUG Dec 06 15:57:34 systemd[1]: trilium.service: Failed with result '\''exit-code'\''.
422589 DEBUG Dec 06 15:57:35 systemd[1]: trilium.service: Scheduled restart job, restart counter is at 5.
422589 DEBUG Dec 06 15:57:35 systemd[1]: Stopped Trilium: notes server.
422590 DEBUG Dec 06 15:57:35 systemd[1]: trilium.service: Start request repeated too quickly.
422590 DEBUG Dec 06 15:57:35 systemd[1]: trilium.service: Failed with result '\''exit-code'\''.
422590 DEBUG Dec 06 15:57:35 systemd[1]: Failed to start Trilium: notes server.'
422590 DEBUG + echo -e 'Dec 06 15:57:34 node[9418]:     at Module._extensions..node (node:internal/modules/cjs/loader:1327:18)
422591 DEBUG Dec 06 15:57:34 node[9418]:     at Module.load (node:internal/modules/cjs/loader:1091:32)
422591 DEBUG Dec 06 15:57:34 node[9418]:     at Module._load (node:internal/modules/cjs/loader:938:12)
422591 DEBUG Dec 06 15:57:34 node[9418]:     at Module.require (node:internal/modules/cjs/loader:1115:19)
422591 DEBUG Dec 06 15:57:34 node[9418]:     at require (node:internal/modules/helpers:130:18)
422592 DEBUG Dec 06 15:57:34 node[9418]:     at bindings (/var/www/trilium/node_modules/bindings/bindings.js:112:48)
422592 DEBUG Dec 06 15:57:34 node[9418]:     at Object.<anonymous> (/var/www/trilium/node_modules/better-sqlite3/lib/database.js:9:24)
422592 DEBUG Dec 06 15:57:34 node[9418]:     at Module._compile (node:internal/modules/cjs/loader:1241:14)
422593 DEBUG Dec 06 15:57:34 node[9418]:     at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
422593 DEBUG Dec 06 15:57:34 node[9418]:     at Module.load (node:internal/modules/cjs/loader:1091:32) {
422593 DEBUG Dec 06 15:57:34 node[9418]:   code: '\''ERR_DLOPEN_FAILED'\''
422594 DEBUG Dec 06 15:57:34 node[9418]: }
422594 DEBUG Dec 06 15:57:34 node[9418]: Node.js v20.7.0

Tried to rebuild npm as mentioned here: Broken after update: 502 Bad Gateway · Issue #47 · YunoHost-Apps/trilium_ynh · GitHub
Got this:

root@yuno:/home/admin# cd /var/www/trilium/
root@yuno:/var/www/trilium# su -g www-data trilium -s /bin/bash
trilium@yuno:~$ npm rebuild
npm ERR! code 1
npm ERR! path /var/www/trilium/node_modules/better-sqlite3
npm ERR! command failed
npm ERR! command sh -c prebuild-install || npm run build-release
npm ERR! > better-sqlite3@7.4.5 build-release
npm ERR! > node-gyp rebuild --release
npm ERR!
npm ERR!
npm ERR! make: Entering directory '/var/www/trilium/node_modules/better-sqlite3/build'
npm ERR!   TOUCH b857c92884e9598d609f6be182a2595df7a8e00f.intermediate
npm ERR!   ACTION deps_sqlite3_gyp_locate_sqlite3_target_extract_sqlite3 b857c92884e9598d609f6be182a2595df7a8e00f.intermediate
npm ERR!   TOUCH Release/obj.target/deps/locate_sqlite3.stamp
npm ERR!   CC(target) Release/obj.target/sqlite3/gen/sqlite3/sqlite3.o
npm ERR! rm -f Release/obj.target/deps/sqlite3.a Release/obj.target/deps/sqlite3.a.ar-file-list; mkdir -p `dirname Release/obj.target/deps/sqlite3.a`
npm ERR! ar crs Release/obj.target/deps/sqlite3.a @Release/obj.target/deps/sqlite3.a.ar-file-list
npm ERR!   COPY Release/sqlite3.a
npm ERR!   CXX(target) Release/obj.target/better_sqlite3/src/better_sqlite3.o
npm ERR! rm b857c92884e9598d609f6be182a2595df7a8e00f.intermediate
npm ERR! make: Leaving directory '/var/www/trilium/node_modules/better-sqlite3/build'
npm ERR! prebuild-install warn install No prebuilt binaries found (target=20.10.0 runtime=node arch=x64 libc= platform=linux)
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.0.1
npm ERR! gyp info using node@20.10.0 | linux | x64
npm ERR! gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3"
npm ERR! gyp http GET https://nodejs.org/download/release/v20.10.0/node-v20.10.0-headers.tar.gz
npm ERR! gyp http 200 https://nodejs.org/download/release/v20.10.0/node-v20.10.0-headers.tar.gz
npm ERR! gyp http GET https://nodejs.org/download/release/v20.10.0/SHASUMS256.txt
npm ERR! gyp http 200 https://nodejs.org/download/release/v20.10.0/SHASUMS256.txt
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/var/www/trilium/node_modules/better-sqlite3/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/var/www/trilium/.cache/node-gyp/20.10.0/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/var/www/trilium/.cache/node-gyp/20.10.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/var/www/trilium/.cache/node-gyp/20.10.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/var/www/trilium/node_modules/better-sqlite3',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ./src/better_sqlite3.lzz:11,
npm ERR!                  from ../src/better_sqlite3.cpp:4:
npm ERR! /var/www/trilium/.cache/node-gyp/20.10.0/include/node/node.h:1192:7: warning: cast between incompatible function types from ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Context>)’ to ‘node::addon_context_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Context>, void*)’} [-Wcast-function-type]
npm ERR!  1192 |       (node::addon_context_register_func) (regfunc),                  \
npm ERR!       |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! /var/www/trilium/.cache/node-gyp/20.10.0/include/node/node.h:1210:3: note: in expansion of macro ‘NODE_MODULE_CONTEXT_AWARE_X’
npm ERR!  1210 |   NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, NULL, 0)
npm ERR!       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! /var/www/trilium/.cache/node-gyp/20.10.0/include/node/node.h:1241:3: note: in expansion of macro ‘NODE_MODULE_CONTEXT_AWARE’
npm ERR!  1241 |   NODE_MODULE_CONTEXT_AWARE(NODE_GYP_MODULE_NAME,                     \
npm ERR!       |   ^~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! ./src/better_sqlite3.lzz:67:1: note: in expansion of macro ‘NODE_MODULE_INIT’
npm ERR! ./src/util/macros.lzz: In function ‘void SetPrototypeGetter(v8::Isolate*, v8::Local<v8::External>, v8::Local<v8::FunctionTemplate>, const char*, v8::AccessorGetterCallback)’:
npm ERR! ./src/util/macros.lzz:157:21: error: ‘v8::AccessorSignature’ has not been declared
npm ERR! ./src/util/binder.lzz: In static member function ‘static bool Binder::IsPlainObject(v8::Isolate*, v8::Local<v8::Object>)’:
npm ERR! ./src/util/binder.lzz:37:51: error: ‘class v8::Object’ has no member named ‘CreationContext’; did you mean ‘GetCreationContext’?
npm ERR! ./src/util/data.lzz: In function ‘v8::Local<v8::Value> Data::GetValueJS(v8::Isolate*, sqlite3_stmt*, int, bool)’:
npm ERR! ./src/util/data.lzz:73:92: warning: this statement may fall through [-Wimplicit-fallthrough=]
npm ERR! ./src/util/data.lzz:73:197: note: here
npm ERR! ./src/util/data.lzz: In function ‘v8::Local<v8::Value> Data::GetValueJS(v8::Isolate*, sqlite3_value*, bool)’:
npm ERR! ./src/util/data.lzz:77:81: warning: this statement may fall through [-Wimplicit-fallthrough=]
npm ERR! ./src/util/data.lzz:77:175: note: here
npm ERR! make: *** [better_sqlite3.target.mk:125: Release/obj.target/better_sqlite3/src/better_sqlite3.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
npm ERR! gyp ERR! System Linux 5.10.0-26-amd64
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
npm ERR! gyp ERR! cwd /var/www/trilium/node_modules/better-sqlite3
npm ERR! gyp ERR! node -v v20.10.0
npm ERR! gyp ERR! node-gyp -v v10.0.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: /var/www/trilium/.npm/_logs/2023-12-06T15_06_03_621Z-debug-0.log

Can you please share full install/upgrade logs? This is suspicious given installer is meant to use NodeJS v18 and your service clearly runs with NodeJS v20.

Thanks for your quick reply. Do you mean this:

description: Upgrade the 'trilium' app
log_path: /var/log/yunohost/categories/operation/20231206-151457-app_upgrade-trilium.log
logs:
  - 2023-12-06 16:20:54,572: DEBUG - Dec 06 16:15:59 systemd[1]: Failed to start Trilium: notes server.'
  - 2023-12-06 16:20:54,572: DEBUG - + echo -e 'Dec 06 16:15:57 systemd[1]: trilium.service: Consumed 1.046s CPU time.
  - 2023-12-06 16:20:54,572: DEBUG - Dec 06 16:15:57 systemd[1]: Started Trilium: notes server.
  - 2023-12-06 16:20:54,572: DEBUG - Dec 06 16:15:58 node[18841]: App db version is 227, while db version is 213. Migration needed.
  - 2023-12-06 16:20:54,573: DEBUG - Dec 06 16:15:58 node[18841]: ERROR: Direct migration from your current version is not supported. Please upgrade to the latest v0.60.X first and only then to this version.
  - 2023-12-06 16:20:54,573: DEBUG - Dec 06 16:15:58 systemd[1]: trilium.service: Main process exited, code=exited, status=1/FAILURE
  - 2023-12-06 16:20:54,573: DEBUG - Dec 06 16:15:58 systemd[1]: trilium.service: Failed with result '\''exit-code'\''.
  - 2023-12-06 16:20:54,573: DEBUG - Dec 06 16:15:58 systemd[1]: trilium.service: Consumed 1.139s CPU time.
  - 2023-12-06 16:20:54,573: DEBUG - Dec 06 16:15:58 systemd[1]: trilium.service: Scheduled restart job, restart counter is at 4.
  - 2023-12-06 16:20:54,573: DEBUG - Dec 06 16:15:58 systemd[1]: Stopped Trilium: notes server.
  - 2023-12-06 16:20:54,574: DEBUG - Dec 06 16:15:58 systemd[1]: trilium.service: Consumed 1.139s CPU time.
  - 2023-12-06 16:20:54,574: DEBUG - Dec 06 16:15:58 systemd[1]: Started Trilium: notes server.
  - 2023-12-06 16:20:54,574: DEBUG - Dec 06 16:15:59 node[18859]: App db version is 227, while db version is 213. Migration needed.
  - 2023-12-06 16:20:54,574: DEBUG - Dec 06 16:15:59 node[18859]: ERROR: Direct migration from your current version is not supported. Please upgrade to the latest v0.60.X first and only then to this version.
  - 2023-12-06 16:20:54,574: DEBUG - Dec 06 16:15:59 systemd[1]: trilium.service: Main process exited, code=exited, status=1/FAILURE
  - 2023-12-06 16:20:54,574: DEBUG - Dec 06 16:15:59 systemd[1]: trilium.service: Failed with result '\''exit-code'\''.
  - 2023-12-06 16:20:54,575: DEBUG - Dec 06 16:15:59 systemd[1]: trilium.service: Scheduled restart job, restart counter is at 5.
  - 2023-12-06 16:20:54,575: DEBUG - Dec 06 16:15:59 systemd[1]: Stopped Trilium: notes server.
  - 2023-12-06 16:20:54,575: DEBUG - Dec 06 16:15:59 systemd[1]: trilium.service: Start request repeated too quickly.
  - 2023-12-06 16:20:54,575: DEBUG - Dec 06 16:15:59 systemd[1]: trilium.service: Failed with result '\''exit-code'\''.
  - 2023-12-06 16:20:54,575: DEBUG - Dec 06 16:15:59 systemd[1]: Failed to start Trilium: notes server.'
  - 2023-12-06 16:20:54,575: DEBUG - + '[' -e systemd ']'
  - 2023-12-06 16:20:54,576: DEBUG - + ynh_clean_check_starting
  - 2023-12-06 16:20:54,576: DEBUG - + '[' -n 18777 ']'
  - 2023-12-06 16:20:54,576: DEBUG - + kill -SIGTERM 18777
  - 2023-12-06 16:20:54,576: DEBUG - + '[' -n /tmp/tmp.HxLDJKoQa9 ']'
  - 2023-12-06 16:20:54,576: DEBUG - + ynh_secure_remove --file=/tmp/tmp.HxLDJKoQa9
  - 2023-12-06 16:20:54,576: DEBUG - + local legacy_args=f
  - 2023-12-06 16:20:54,576: DEBUG - + args_array=(['f']='file=')
  - 2023-12-06 16:20:54,576: DEBUG - + local -A args_array
  - 2023-12-06 16:20:54,577: DEBUG - + local file
  - 2023-12-06 16:20:54,577: DEBUG - + ynh_handle_getopts_args --file=/tmp/tmp.HxLDJKoQa9
  - 2023-12-06 16:20:54,577: DEBUG - + set +o xtrace
  - 2023-12-06 16:20:54,577: DEBUG - + set +o xtrace
  - 2023-12-06 16:20:54,587: DEBUG - + ynh_script_progression '--message=Upgrade of trilium completed' --last
  - 2023-12-06 16:20:54,587: DEBUG - + set +o xtrace
  - 2023-12-06 16:20:54,654: DEBUG - + set +o xtrace
  - 2023-12-06 16:20:54,668: DEBUG - + echo '! Helper used in legacy mode !'
  - 2023-12-06 16:20:54,669: DEBUG - + set +x
  - 2023-12-06 16:20:54,671: DEBUG - + echo '[####################] > Upgrade of trilium completed'
  - 2023-12-06 16:20:54,671: INFO - [####################] > Upgrade of trilium completed
  - 2023-12-06 16:20:54,672: DEBUG - + set -o xtrace
  - 2023-12-06 16:20:54,672: DEBUG - + ynh_exit_properly
  - 2023-12-06 16:20:54,672: DEBUG - + local exit_code=0
  - 2023-12-06 16:20:54,672: DEBUG - + [[ upgrade =~ ^install$|^upgrade$|^restore$ ]]
  - 2023-12-06 16:20:54,672: DEBUG - + rm -rf /var/cache/yunohost/download/
  - 2023-12-06 16:20:54,673: DEBUG - + '[' 0 -eq 0 ']'
  - 2023-12-06 16:20:54,673: DEBUG - + exit 0
  - 2023-12-06 16:20:55,676: DEBUG - Checking that required services are up and running...
  - 2023-12-06 16:20:57,061: SUCCESS - trilium upgraded
metadata:
  ended_at: 2023-12-06 16:20:57
  env:
    YNH_APP_ACTION: upgrade
    YNH_APP_BASEDIR: /var/cache/yunohost/app_tmp_work_dirs/app_dwl5ua1e
    YNH_APP_CURRENT_VERSION: 0.60.4~ynh1
    YNH_APP_ID: trilium
    YNH_APP_INSTANCE_NAME: trilium
    YNH_APP_INSTANCE_NUMBER: 1
    YNH_APP_MANIFEST_VERSION: 0.61.15~ynh1
    YNH_APP_PACKAGING_FORMAT: 2.0
    YNH_APP_UPGRADE_TYPE: UPGRADE_APP
    YNH_ARCH: amd64
    YNH_DEBIAN_VERSION: bullseye
  error: None
  interface: cli
  operation: app_upgrade
  parent: None
  related_to:
    - app
    - trilium
  started_at: 2023-12-06 16:14:57
  success: True
  yunohost_version: 11.2.8
metadata_path: /var/log/yunohost/categories/operation/20231206-151457-app_upgrade-trilium.yml
name: 20231206-151457-app_upgrade-trilium

I also have this systemctl log. Here it says Node.js v18.18.2 ??

root@yuno:/var/www/trilium# journalctl -u trilium.service -e
Dec 06 16:28:17 yuno.myserver.xyz node[21009]:     at Module._extensions..node (node:internal/modules/cjs/loader:1340:18)
Dec 06 16:28:17 yuno.myserver.xyz node[21009]:     at Module.load (node:internal/modules/cjs/loader:1119:32)
Dec 06 16:28:17 yuno.myserver.xyz node[21009]:     at Module._load (node:internal/modules/cjs/loader:960:12)
Dec 06 16:28:17 yuno.myserver.xyz node[21009]:     at Module.require (node:internal/modules/cjs/loader:1143:19)
Dec 06 16:28:17 yuno.myserver.xyz node[21009]:     at require (node:internal/modules/cjs/helpers:119:18)
Dec 06 16:28:17 yuno.myserver.xyz node[21009]:     at bindings (/var/www/trilium/node_modules/bindings/bindings.js:112:48)
Dec 06 16:28:17 yuno.myserver.xyz node[21009]:     at new Database (/var/www/trilium/node_modules/better-sqlite3/lib/database.js:48:64)
Dec 06 16:28:17 yuno.myserver.xyz node[21009]:     at Object.<anonymous> (/var/www/trilium/src/services/sql.js:13:22)
Dec 06 16:28:17 yuno.myserver.xyz node[21009]:     at Module._compile (node:internal/modules/cjs/loader:1256:14)
Dec 06 16:28:17 yuno.myserver.xyz node[21009]:     at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) {
Dec 06 16:28:17 yuno.myserver.xyz node[21009]:   code: 'ERR_DLOPEN_FAILED'
Dec 06 16:28:17 yuno.myserver.xyz node[21009]: }
Dec 06 16:28:17 yuno.myserver.xyz node[21009]: Node.js v18.18.2
Dec 06 16:28:17 yuno.myserver.xyz systemd[1]: trilium.service: Main process exited, code=exited, status=1/FAILURE
Dec 06 16:28:17 yuno.myserver.xyz systemd[1]: trilium.service: Failed with result 'exit-code'.
Dec 06 16:28:17 yuno.myserver.xyz systemd[1]: trilium.service: Scheduled restart job, restart counter is at 4.
Dec 06 16:28:17 yuno.myserver.xyz systemd[1]: Stopped Trilium: notes server.
Dec 06 16:28:17 yuno.myserver.xyz systemd[1]: Started Trilium: notes server.
Dec 06 16:28:18 yuno.myserver.xyz node[21018]: /var/www/trilium/node_modules/bindings/bindings.js:121
Dec 06 16:28:18 yuno.myserver.xyz node[21018]:         throw e;
Dec 06 16:28:18 yuno.myserver.xyz node[21018]:         ^
Dec 06 16:28:18 yuno.myserver.xyz node[21018]: Error: The module '/var/www/trilium/node_modules/better-sqlite3/build/Release/better_sqlite3.node'
Dec 06 16:28:18 yuno.myserver.xyz node[21018]: was compiled against a different Node.js version using
Dec 06 16:28:18 yuno.myserver.xyz node[21018]: NODE_MODULE_VERSION 115. This version of Node.js requires
Dec 06 16:28:18 yuno.myserver.xyz node[21018]: NODE_MODULE_VERSION 108. Please try re-compiling or re-installing
Dec 06 16:28:18 yuno.myserver.xyz node[21018]: the module (for instance, using `npm rebuild` or `npm install`).
Dec 06 16:28:18 yuno.myserver.xyz node[21018]:     at Module._extensions..node (node:internal/modules/cjs/loader:1340:18)
Dec 06 16:28:18 yuno.myserver.xyz node[21018]:     at Module.load (node:internal/modules/cjs/loader:1119:32)
Dec 06 16:28:18 yuno.myserver.xyz node[21018]:     at Module._load (node:internal/modules/cjs/loader:960:12)
Dec 06 16:28:18 yuno.myserver.xyz node[21018]:     at Module.require (node:internal/modules/cjs/loader:1143:19)
Dec 06 16:28:18 yuno.myserver.xyz node[21018]:     at require (node:internal/modules/cjs/helpers:119:18)
Dec 06 16:28:18 yuno.myserver.xyz node[21018]:     at bindings (/var/www/trilium/node_modules/bindings/bindings.js:112:48)
Dec 06 16:28:18 yuno.myserver.xyz node[21018]:     at new Database (/var/www/trilium/node_modules/better-sqlite3/lib/database.js:48:64)
Dec 06 16:28:18 yuno.myserver.xyz node[21018]:     at Object.<anonymous> (/var/www/trilium/src/services/sql.js:13:22)
Dec 06 16:28:18 yuno.myserver.xyz node[21018]:     at Module._compile (node:internal/modules/cjs/loader:1256:14)
Dec 06 16:28:18 yuno.myserver.xyz node[21018]:     at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) {
Dec 06 16:28:18 yuno.myserver.xyz node[21018]:   code: 'ERR_DLOPEN_FAILED'
Dec 06 16:28:18 yuno.myserver.xyz node[21018]: }
Dec 06 16:28:18 yuno.myserver.xyz node[21018]: Node.js v18.18.2
Dec 06 16:28:18 yuno.myserver.xyz systemd[1]: trilium.service: Main process exited, code=exited, status=1/FAILURE
Dec 06 16:28:18 yuno.myserver.xyz systemd[1]: trilium.service: Failed with result 'exit-code'.
Dec 06 16:28:18 yuno.myserver.xyz systemd[1]: trilium.service: Scheduled restart job, restart counter is at 5.
Dec 06 16:28:18 yuno.myserver.xyz systemd[1]: Stopped Trilium: notes server.
Dec 06 16:28:18 yuno.myserver.xyz systemd[1]: trilium.service: Start request repeated too quickly.
Dec 06 16:28:18 yuno.myserver.xyz systemd[1]: trilium.service: Failed with result 'exit-code'.
Dec 06 16:28:18 yuno.myserver.xyz systemd[1]: Failed to start Trilium: notes server.

The problem is quite apparent here. Do you have pre-upgrade backup available for 0.59.2 available still?

You’ll need to manually update to 0.60.x and only then to latest.

ONLY DO THIS IF YOU HAVE 0.59.2 BACKUP AVAILABLE, PERMANENT DATA LOSS AHEAD OTHERWISE

To perform this 2-step upgrade

  1. Uninstall the app
  2. Restore 0.59.2
  3. Upgrade to 0.60.4 with sudo yunohost app upgrade trilium -u https://github.com/YunoHost-Apps/trilium_ynh/tree/f6d40ba29a50b429138c1a636cd1be239748f2ad
  4. Upgrade to latest from web interface.

Hm, I did upgrad from 0.59.2 via 0.60.x. But I will give it another try.

I have reset the version to 0.59.2 by restoring an old snapshot of the VPS. Then I successfully tested that it runs including Trilium 0.59.2

This is what happens after upgrading from 0.59.2 to 0.60.4 via cli:

Info: Now upgrading trilium...
Info: Creating a safety backup prior to the upgrade
Info: Collecting files to be backed up for trilium...
Info: Declaring files to be backed up...
Info: /home/yunohost.app/trilium will not be saved, because 'BACKUP_CORE_ONLY' is set.
Info: Backup script completed for trilium. (YunoHost will then actually copy those files to the archive).
Info: Creating a backup archive from the collected files...
Info: The archive will contain about 359.5MB of data.
Success! Backup created: trilium-pre-upgrade2
Success! Backup deleted: trilium-pre-upgrade1
Info: Updating sources...
Info: Updating system_user...
Info: Updating install_dir...
Info: Updating data_dir...
Info: Updating permissions...
Info: Updating ports...
Info: Updating apt...
Info: [....................] > Stopping a systemd service...
Info: [+++.................] > Upgrading source files...
Info: [###+................] > Upgrading nodejs...
Info: [####++++++++++++++..] > Installing Node.js packages ...
Info: [##################+.] > Upgrading system configurations related to trilium...
Info: [###################.] > Updating a configuration file...
Info: [###################.] > Starting a systemd service...
Warning: (this may take some time)
Warning: The service trilium didn't fully executed the action start before the timeout.
Warning: Please find here an extract of the end of the log of the service trilium:
Warning: Dec 06 17:52:47 node[9363]:     at Module._extensions..node (node:internal/modules/cjs/loader:1327:18)
Warning: Dec 06 17:52:47 node[9363]:     at Module.load (node:internal/modules/cjs/loader:1091:32)
Warning: Dec 06 17:52:47 node[9363]:     at Module._load (node:internal/modules/cjs/loader:938:12)
Warning: Dec 06 17:52:47 node[9363]:     at Module.require (node:internal/modules/cjs/loader:1115:19)
Warning: Dec 06 17:52:47 node[9363]:     at require (node:internal/modules/helpers:130:18)
Warning: Dec 06 17:52:47 node[9363]:     at bindings (/var/www/trilium/node_modules/bindings/bindings.js:112:48)
Warning: Dec 06 17:52:47 node[9363]:     at Object.<anonymous> (/var/www/trilium/node_modules/better-sqlite3/lib/database.js:9:24)
Warning: Dec 06 17:52:47 node[9363]:     at Module._compile (node:internal/modules/cjs/loader:1241:14)
Warning: Dec 06 17:52:47 node[9363]:     at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
Warning: Dec 06 17:52:47 node[9363]:     at Module.load (node:internal/modules/cjs/loader:1091:32) {
Warning: Dec 06 17:52:47 node[9363]:   code: 'ERR_DLOPEN_FAILED'
Warning: Dec 06 17:52:47 node[9363]: }
Warning: Dec 06 17:52:47 node[9363]: Node.js v20.7.0
Warning: Dec 06 17:52:47 systemd[1]: trilium.service: Main process exited, code=exited, status=1/FAILURE
Warning: Dec 06 17:52:47 systemd[1]: trilium.service: Failed with result 'exit-code'.
Warning: Dec 06 17:52:47 systemd[1]: trilium.service: Scheduled restart job, restart counter is at 5.
Warning: Dec 06 17:52:47 systemd[1]: Stopped Trilium: notes server.
Warning: Dec 06 17:52:47 systemd[1]: trilium.service: Start request repeated too quickly.
Warning: Dec 06 17:52:47 systemd[1]: trilium.service: Failed with result 'exit-code'.
Warning: Dec 06 17:52:47 systemd[1]: Failed to start Trilium: notes server.
Info: [####################] > Upgrade of trilium completed
Success! trilium upgraded
Success! Upgrade complete

Then I upgraded via webinterface in spite of the error:

description: Upgrade the 'trilium' app
log_path: /var/log/yunohost/categories/operation/20231206-171047-app_upgrade-trilium.log
logs:
  - 2023-12-06 18:16:45,669: DEBUG - Dec 06 18:11:50 systemd[1]: Failed to start Trilium: notes server.'
  - 2023-12-06 18:16:45,669: DEBUG - + '[' -e systemd ']'
  - 2023-12-06 18:16:45,669: DEBUG - + ynh_clean_check_starting
  - 2023-12-06 18:16:45,669: DEBUG - + '[' -n 19137 ']'
  - 2023-12-06 18:16:45,669: DEBUG - + kill -SIGTERM 19137
  - 2023-12-06 18:16:45,669: DEBUG - + '[' -n /tmp/tmp.2mcwLZNslM ']'
  - 2023-12-06 18:16:45,669: DEBUG - + ynh_secure_remove --file=/tmp/tmp.2mcwLZNslM
  - 2023-12-06 18:16:45,669: DEBUG - + local legacy_args=f
  - 2023-12-06 18:16:45,669: DEBUG - + args_array=(['f']='file=')
  - 2023-12-06 18:16:45,669: DEBUG - + local -A args_array
  - 2023-12-06 18:16:45,670: DEBUG - + local file
  - 2023-12-06 18:16:45,670: DEBUG - + ynh_handle_getopts_args --file=/tmp/tmp.2mcwLZNslM
  - 2023-12-06 18:16:45,670: DEBUG - + set +o xtrace
  - 2023-12-06 18:16:45,670: WARNING - Dec 06 18:11:48 node[19201]: App db version is 227, while db version is 213. Migration needed.
  - 2023-12-06 18:16:45,670: WARNING - Dec 06 18:11:48 node[19201]: ERROR: Direct migration from your current version is not supported. Please upgrade to the latest v0.60.X first and only then to this version.
  - 2023-12-06 18:16:45,671: WARNING - Dec 06 18:11:48 systemd[1]: trilium.service: Main process exited, code=exited, status=1/FAILURE
  - 2023-12-06 18:16:45,671: WARNING - Dec 06 18:11:48 systemd[1]: trilium.service: Failed with result 'exit-code'.
  - 2023-12-06 18:16:45,671: WARNING - Dec 06 18:11:48 systemd[1]: trilium.service: Consumed 1.030s CPU time.
  - 2023-12-06 18:16:45,671: WARNING - Dec 06 18:11:49 systemd[1]: trilium.service: Scheduled restart job, restart counter is at 4.
  - 2023-12-06 18:16:45,672: WARNING - Dec 06 18:11:49 systemd[1]: Stopped Trilium: notes server.
  - 2023-12-06 18:16:45,672: WARNING - Dec 06 18:11:49 systemd[1]: trilium.service: Consumed 1.030s CPU time.
  - 2023-12-06 18:16:45,672: WARNING - Dec 06 18:11:49 systemd[1]: Started Trilium: notes server.
  - 2023-12-06 18:16:45,673: WARNING - Dec 06 18:11:50 node[19218]: App db version is 227, while db version is 213. Migration needed.
  - 2023-12-06 18:16:45,673: WARNING - Dec 06 18:11:50 node[19218]: ERROR: Direct migration from your current version is not supported. Please upgrade to the latest v0.60.X first and only then to this version.
  - 2023-12-06 18:16:45,673: WARNING - Dec 06 18:11:50 systemd[1]: trilium.service: Main process exited, code=exited, status=1/FAILURE
  - 2023-12-06 18:16:45,673: WARNING - Dec 06 18:11:50 systemd[1]: trilium.service: Failed with result 'exit-code'.
  - 2023-12-06 18:16:45,673: WARNING - Dec 06 18:11:50 systemd[1]: trilium.service: Consumed 1.073s CPU time.
  - 2023-12-06 18:16:45,674: WARNING - Dec 06 18:11:50 systemd[1]: trilium.service: Scheduled restart job, restart counter is at 5.
  - 2023-12-06 18:16:45,674: WARNING - Dec 06 18:11:50 systemd[1]: Stopped Trilium: notes server.
  - 2023-12-06 18:16:45,674: WARNING - Dec 06 18:11:50 systemd[1]: trilium.service: Consumed 1.073s CPU time.
  - 2023-12-06 18:16:45,674: WARNING - Dec 06 18:11:50 systemd[1]: trilium.service: Start request repeated too quickly.
  - 2023-12-06 18:16:45,675: WARNING - Dec 06 18:11:50 systemd[1]: trilium.service: Failed with result 'exit-code'.
  - 2023-12-06 18:16:45,675: WARNING - Dec 06 18:11:50 systemd[1]: Failed to start Trilium: notes server.
  - 2023-12-06 18:16:45,675: DEBUG - + set +o xtrace
  - 2023-12-06 18:16:45,692: DEBUG - + ynh_script_progression '--message=Upgrade of trilium completed' --last
  - 2023-12-06 18:16:45,693: DEBUG - + set +o xtrace
  - 2023-12-06 18:16:45,775: DEBUG - + set +o xtrace
  - 2023-12-06 18:16:45,793: DEBUG - + echo '! Helper used in legacy mode !'
  - 2023-12-06 18:16:45,794: DEBUG - + set +x
  - 2023-12-06 18:16:45,797: DEBUG - + echo '[####################] > Upgrade of trilium completed'
  - 2023-12-06 18:16:45,797: INFO - [####################] > Upgrade of trilium completed
  - 2023-12-06 18:16:45,798: DEBUG - + set -o xtrace
  - 2023-12-06 18:16:45,798: DEBUG - + ynh_exit_properly
  - 2023-12-06 18:16:45,798: DEBUG - + local exit_code=0
  - 2023-12-06 18:16:45,798: DEBUG - + [[ upgrade =~ ^install$|^upgrade$|^restore$ ]]
  - 2023-12-06 18:16:45,799: DEBUG - + rm -rf /var/cache/yunohost/download/
  - 2023-12-06 18:16:45,799: DEBUG - + '[' 0 -eq 0 ']'
  - 2023-12-06 18:16:45,799: DEBUG - + exit 0
  - 2023-12-06 18:16:46,803: DEBUG - Checking that required services are up and running...
  - 2023-12-06 18:16:48,313: SUCCESS - trilium aktualisiert
metadata:
  ended_at: 2023-12-06 18:16:48
  env:
    YNH_APP_ACTION: upgrade
    YNH_APP_BASEDIR: /var/cache/yunohost/app_tmp_work_dirs/app__co6ju15
    YNH_APP_CURRENT_VERSION: 0.60.4~ynh1
    YNH_APP_ID: trilium
    YNH_APP_INSTANCE_NAME: trilium
    YNH_APP_INSTANCE_NUMBER: 1
    YNH_APP_MANIFEST_VERSION: 0.61.15~ynh1
    YNH_APP_PACKAGING_FORMAT: 2.0
    YNH_APP_UPGRADE_TYPE: UPGRADE_APP
    YNH_ARCH: amd64
    YNH_DEBIAN_VERSION: bullseye
  error: None
  interface: api
  operation: app_upgrade
  parent: None
  related_to:
    - app
    - trilium
  started_at: 2023-12-06 18:10:47
  success: True
  yunohost_version: 11.2.8
metadata_path: /var/log/yunohost/categories/operation/20231206-171047-app_upgrade-trilium.yml
name: 20231206-171047-app_upgrade-trilium

As you see there is again “Direct migration from your current version is not supported.”. Any other idea?

When this intermediate upgrade fails - can you please follow the instructions from this comment? Namely

# cd /var/www/trilium
# su -g www-data trilium -s /bin/bash
$ npm rebuild
$ exit
# systemctl restart trilium

If this succeeds - nice, proceed to latest version. If not - can you please share the logs?

EDIT: And by ‘this succeeds’ I mean you have 0.60.4 up and running.

Also, can you please share full upgrade logs for 0.60.4 (exportable from web admin Tools->Logs).

Here is the full log from upgrade to 0.60.4 : https://paste.yunohost.org/raw/wicelipumi

npm rebuild fails:

npm ERR! code 1
npm ERR! path /var/www/trilium/node_modules/better-sqlite3
npm ERR! command failed
npm ERR! command sh -c prebuild-install || npm run build-release
npm ERR! > better-sqlite3@7.4.5 build-release
npm ERR! > node-gyp rebuild --release
npm ERR!
npm ERR!
npm ERR! make: Entering directory '/var/www/trilium/node_modules/better-sqlite3/build'
npm ERR!   TOUCH b857c92884e9598d609f6be182a2595df7a8e00f.intermediate
npm ERR!   ACTION deps_sqlite3_gyp_locate_sqlite3_target_extract_sqlite3 b857c92884e9598d609f6be182a2595df7a8e00f.intermediate
npm ERR!   TOUCH Release/obj.target/deps/locate_sqlite3.stamp
npm ERR!   CC(target) Release/obj.target/sqlite3/gen/sqlite3/sqlite3.o
npm ERR! rm -f Release/obj.target/deps/sqlite3.a Release/obj.target/deps/sqlite3.a.ar-file-list; mkdir -p `dirname Release/obj.target/deps/sqlite3.a`
npm ERR! ar crs Release/obj.target/deps/sqlite3.a @Release/obj.target/deps/sqlite3.a.ar-file-list
npm ERR!   COPY Release/sqlite3.a
npm ERR!   CXX(target) Release/obj.target/better_sqlite3/src/better_sqlite3.o
npm ERR! rm b857c92884e9598d609f6be182a2595df7a8e00f.intermediate
npm ERR! make: Leaving directory '/var/www/trilium/node_modules/better-sqlite3/build'
npm ERR! prebuild-install warn install No prebuilt binaries found (target=20.10.0 runtime=node arch=x64 libc= platform=linux)
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.0.1
npm ERR! gyp info using node@20.10.0 | linux | x64
npm ERR! gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3"
npm ERR! gyp http GET https://nodejs.org/download/release/v20.10.0/node-v20.10.0-headers.tar.gz
npm ERR! gyp http 200 https://nodejs.org/download/release/v20.10.0/node-v20.10.0-headers.tar.gz
npm ERR! gyp http GET https://nodejs.org/download/release/v20.10.0/SHASUMS256.txt
npm ERR! gyp http 200 https://nodejs.org/download/release/v20.10.0/SHASUMS256.txt
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/var/www/trilium/node_modules/better-sqlite3/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/var/www/trilium/.cache/node-gyp/20.10.0/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/var/www/trilium/.cache/node-gyp/20.10.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/var/www/trilium/.cache/node-gyp/20.10.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/var/www/trilium/node_modules/better-sqlite3',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ./src/better_sqlite3.lzz:11,
npm ERR!                  from ../src/better_sqlite3.cpp:4:
npm ERR! /var/www/trilium/.cache/node-gyp/20.10.0/include/node/node.h:1192:7: warning: cast between incompatible function types from ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Context>)’ to ‘node::addon_context_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Context>, void*)’} [-Wcast-function-type]
npm ERR!  1192 |       (node::addon_context_register_func) (regfunc),                  \
npm ERR!       |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! /var/www/trilium/.cache/node-gyp/20.10.0/include/node/node.h:1210:3: note: in expansion of macro ‘NODE_MODULE_CONTEXT_AWARE_X’
npm ERR!  1210 |   NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, NULL, 0)
npm ERR!       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! /var/www/trilium/.cache/node-gyp/20.10.0/include/node/node.h:1241:3: note: in expansion of macro ‘NODE_MODULE_CONTEXT_AWARE’
npm ERR!  1241 |   NODE_MODULE_CONTEXT_AWARE(NODE_GYP_MODULE_NAME,                     \
npm ERR!       |   ^~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! ./src/better_sqlite3.lzz:67:1: note: in expansion of macro ‘NODE_MODULE_INIT’
npm ERR! ./src/util/macros.lzz: In function ‘void SetPrototypeGetter(v8::Isolate*, v8::Local<v8::External>, v8::Local<v8::FunctionTemplate>, const char*, v8::AccessorGetterCallback)’:
npm ERR! ./src/util/macros.lzz:157:21: error: ‘v8::AccessorSignature’ has not been declared
npm ERR! ./src/util/binder.lzz: In static member function ‘static bool Binder::IsPlainObject(v8::Isolate*, v8::Local<v8::Object>)’:
npm ERR! ./src/util/binder.lzz:37:51: error: ‘class v8::Object’ has no member named ‘CreationContext’; did you mean ‘GetCreationContext’?
npm ERR! ./src/util/data.lzz: In function ‘v8::Local<v8::Value> Data::GetValueJS(v8::Isolate*, sqlite3_stmt*, int, bool)’:
npm ERR! ./src/util/data.lzz:73:92: warning: this statement may fall through [-Wimplicit-fallthrough=]
npm ERR! ./src/util/data.lzz:73:197: note: here
npm ERR! ./src/util/data.lzz: In function ‘v8::Local<v8::Value> Data::GetValueJS(v8::Isolate*, sqlite3_value*, bool)’:
npm ERR! ./src/util/data.lzz:77:81: warning: this statement may fall through [-Wimplicit-fallthrough=]
npm ERR! ./src/util/data.lzz:77:175: note: here
npm ERR! make: *** [better_sqlite3.target.mk:125: Release/obj.target/better_sqlite3/src/better_sqlite3.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
npm ERR! gyp ERR! System Linux 5.10.0-26-amd64
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
npm ERR! gyp ERR! cwd /var/www/trilium/node_modules/better-sqlite3
npm ERR! gyp ERR! node -v v20.10.0
npm ERR! gyp ERR! node-gyp -v v10.0.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: /var/www/trilium/.npm/_logs/2023-12-06T17_52_24_287Z-debug-0.log

I looked at it some more and come up with a modified 0.60.4 version for intermediate upgrade.

Can you please try restoring 0.59.x then updating with this command:

sudo yunohost app upgrade trilium -u https://github.com/orhtej2/trilium_ynh/tree/node_18_0_60_4

If this works proceed with the latest from web admin, if not - you know the drill of sending the logs :wink:

1 Like

Yes, it’s working now. I’m successfully on version 0.61.15!
Thank you very much for your tireless and quick help!

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.