From a2c9974c96b204a9e5c8c1fb532b116ade38de55 Mon Sep 17 00:00:00 2001 From: Stephen Chen <20940639+stephenctw@users.noreply.github.com> Date: Thu, 2 Jul 2026 13:17:20 +0800 Subject: [PATCH 1/2] fix(watchdog): prefer deb-installed cartesi Lua bindings Stale /usr/local cartesi.so copies from older manual installs shadow the machine-emulator .deb module and break CM load (archive v5 vs v6). Set LUA_CPATH_5_4/LUA_PATH_5_4 in the watchdog wrapper and doctor check, matching the cartesi-machine CLI wrapper ordering. --- watchdog/justfile | 2 +- watchdog/sequencer-watchdog | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/watchdog/justfile b/watchdog/justfile index 884ba3d..d3a6998 100644 --- a/watchdog/justfile +++ b/watchdog/justfile @@ -31,5 +31,5 @@ doctor: exit 1; \ } @lua -e "package.cpath = '.deps/lua/?.so;' .. package.cpath; require('lcurl'); print('doctor: lcurl ok')" - @lua -e "package.path = './?.lua;./?/init.lua;' .. package.path; local m=require('watchdog.machine_cartesi').new(); local inst,err=m:load('examples/canonical-app/out/canonical-machine-image'); if not inst then error('doctor: machine_cartesi cannot load devnet image: '..tostring(err)) end; print('doctor: machine_cartesi load ok')" + @LUA_CPATH_5_4="/usr/lib/lua/5.4/?.so;/usr/lib/lua/5.4/?/init.so;${LUA_CPATH_5_4:-;}" LUA_PATH_5_4="/usr/share/lua/5.4/?.lua;/usr/share/lua/5.4/?/init.so;${LUA_PATH_5_4:-;}" lua -e "package.path = './?.lua;./?/init.lua;' .. package.path; local m=require('watchdog.machine_cartesi').new(); local inst,err=m:load('examples/canonical-app/out/canonical-machine-image'); if not inst then error('doctor: machine_cartesi cannot load devnet image: '..tostring(err)) end; print('doctor: machine_cartesi load ok')" @echo "doctor: watchdog toolchain ok" diff --git a/watchdog/sequencer-watchdog b/watchdog/sequencer-watchdog index a92f099..744661f 100755 --- a/watchdog/sequencer-watchdog +++ b/watchdog/sequencer-watchdog @@ -11,6 +11,16 @@ fi lua_root="${CARTESI_WATCHDOG_LUA_ROOT:-/opt/watchdog/lua}" lua_bin="${CARTESI_WATCHDOG_LUA_BIN:-lua5.4}" +# Prefer deb-installed cartesi bindings under /usr/lib over stale /usr/local +# copies left by an older manual install (same ordering as the cartesi-machine +# wrapper shipped in machine-emulator_*.deb). +_cartesi_lua_cpath="/usr/lib/lua/5.4/?.so;/usr/lib/lua/5.4/?/init.so" +_cartesi_lua_path="/usr/share/lua/5.4/?.lua;/usr/share/lua/5.4/?/init.so" +export LUA_CPATH="${_cartesi_lua_cpath};${LUA_CPATH:-;}" +export LUA_PATH="${_cartesi_lua_path};${LUA_PATH:-;}" +export LUA_CPATH_5_4="${_cartesi_lua_cpath};${LUA_CPATH_5_4:-;}" +export LUA_PATH_5_4="${_cartesi_lua_path};${LUA_PATH_5_4:-;}" + cd "${lua_root}" if [[ "$#" -gt 0 && ( "$1" == "init" || "$1" == "tick" ) ]]; then From 92038fcbf0027448873104ef854fba9239e84d68 Mon Sep 17 00:00:00 2001 From: Stephen Chen <20940639+stephenctw@users.noreply.github.com> Date: Thu, 16 Jul 2026 16:28:44 +0800 Subject: [PATCH 2/2] fix(watchdog): use ?/init.lua in LUA_PATH entries LUA_PATH only feeds Lua's source searcher; ?/init.so can never satisfy a pure-Lua init.lua package. Match the cartesi-machine wrapper. --- watchdog/justfile | 2 +- watchdog/sequencer-watchdog | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/watchdog/justfile b/watchdog/justfile index d3a6998..32fac5b 100644 --- a/watchdog/justfile +++ b/watchdog/justfile @@ -31,5 +31,5 @@ doctor: exit 1; \ } @lua -e "package.cpath = '.deps/lua/?.so;' .. package.cpath; require('lcurl'); print('doctor: lcurl ok')" - @LUA_CPATH_5_4="/usr/lib/lua/5.4/?.so;/usr/lib/lua/5.4/?/init.so;${LUA_CPATH_5_4:-;}" LUA_PATH_5_4="/usr/share/lua/5.4/?.lua;/usr/share/lua/5.4/?/init.so;${LUA_PATH_5_4:-;}" lua -e "package.path = './?.lua;./?/init.lua;' .. package.path; local m=require('watchdog.machine_cartesi').new(); local inst,err=m:load('examples/canonical-app/out/canonical-machine-image'); if not inst then error('doctor: machine_cartesi cannot load devnet image: '..tostring(err)) end; print('doctor: machine_cartesi load ok')" + @LUA_CPATH_5_4="/usr/lib/lua/5.4/?.so;/usr/lib/lua/5.4/?/init.so;${LUA_CPATH_5_4:-;}" LUA_PATH_5_4="/usr/share/lua/5.4/?.lua;/usr/share/lua/5.4/?/init.lua;${LUA_PATH_5_4:-;}" lua -e "package.path = './?.lua;./?/init.lua;' .. package.path; local m=require('watchdog.machine_cartesi').new(); local inst,err=m:load('examples/canonical-app/out/canonical-machine-image'); if not inst then error('doctor: machine_cartesi cannot load devnet image: '..tostring(err)) end; print('doctor: machine_cartesi load ok')" @echo "doctor: watchdog toolchain ok" diff --git a/watchdog/sequencer-watchdog b/watchdog/sequencer-watchdog index 744661f..19df961 100755 --- a/watchdog/sequencer-watchdog +++ b/watchdog/sequencer-watchdog @@ -15,7 +15,7 @@ lua_bin="${CARTESI_WATCHDOG_LUA_BIN:-lua5.4}" # copies left by an older manual install (same ordering as the cartesi-machine # wrapper shipped in machine-emulator_*.deb). _cartesi_lua_cpath="/usr/lib/lua/5.4/?.so;/usr/lib/lua/5.4/?/init.so" -_cartesi_lua_path="/usr/share/lua/5.4/?.lua;/usr/share/lua/5.4/?/init.so" +_cartesi_lua_path="/usr/share/lua/5.4/?.lua;/usr/share/lua/5.4/?/init.lua" export LUA_CPATH="${_cartesi_lua_cpath};${LUA_CPATH:-;}" export LUA_PATH="${_cartesi_lua_path};${LUA_PATH:-;}" export LUA_CPATH_5_4="${_cartesi_lua_cpath};${LUA_CPATH_5_4:-;}"