Skip to content

fix(watchdog): prefer deb-installed cartesi Lua bindings#22

Merged
stephenctw merged 2 commits into
mainfrom
fix/watchdog-prefer-deb-cartesi-lua
Jul 16, 2026
Merged

fix(watchdog): prefer deb-installed cartesi Lua bindings#22
stephenctw merged 2 commits into
mainfrom
fix/watchdog-prefer-deb-cartesi-lua

Conversation

@stephenctw

Copy link
Copy Markdown
Collaborator

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.

@stephenctw
stephenctw requested a review from GCdePaula July 2, 2026 05:37
@stephenctw stephenctw self-assigned this Jul 2, 2026
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.
@stephenctw
stephenctw force-pushed the fix/watchdog-prefer-deb-cartesi-lua branch from 3494d41 to a2c9974 Compare July 15, 2026 13:11
Comment thread watchdog/sequencer-watchdog Outdated
# 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"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LUA_PATH only feeds Lua's source searcher, so the ?/init.so entry here is dead — it can never satisfy a require of a pure-Lua <mod>/init.lua. Should be ?/init.lua. As written, an init.lua-packaged module falls through to the ;; compiled-in default (which orders /usr/local/share before /usr/share on Debian-likes), i.e. the exact stale-shadowing this PR is fixing. Note this var flows into both LUA_PATH (l.20) and LUA_PATH_5_4 (l.22), so this one line fixes both. cartesi.so is unaffected (it resolves via cpath).

_cartesi_lua_path="/usr/share/lua/5.4/?.lua;/usr/share/lua/5.4/?/init.lua"

Comment thread watchdog/justfile Outdated
}
@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')"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same ?/init.so copy-paste in the doctor recipe's LUA_PATH_5_4 — swap it to ?/init.lua (the LUA_CPATH_5_4 part with ?/init.so is correct; only the LUA_PATH_5_4 half is wrong).

LUA_PATH only feeds Lua's source searcher; ?/init.so can never satisfy
a pure-Lua init.lua package. Match the cartesi-machine wrapper.
@GCdePaula
GCdePaula self-requested a review July 16, 2026 11:06

@GCdePaula GCdePaula left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@stephenctw
stephenctw merged commit d826406 into main Jul 16, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants