From 3494d414c23ff9f363216225620a016524761274 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] 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