fix(watchdog): prefer deb-installed cartesi Lua bindings#22
Conversation
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.
3494d41 to
a2c9974
Compare
| # 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" |
There was a problem hiding this comment.
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"
| } | ||
| @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')" |
There was a problem hiding this comment.
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.
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.