pkulchenko / ZeroBraneStudio

Lightweight Lua-based IDE for Lua with code completion, syntax highlighting, live coding, remote debugger, and code analyzer; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and other Lua interpreters on Windows, macOS, and Linux
http://studio.zerobrane.com/
Other
2.6k stars 519 forks source link

Debugger hangs when using a shell script wrapper #1097

Closed andrewstarks closed 3 years ago

andrewstarks commented 3 years ago

On the 1.9 builds and also from the master branch:

I'm trying to keep things nicely contained in my project, and so I've used luarocks --init to install libraries in the project folder, along with a wrapper around the lua binary that reads:

#!/bin/sh

LUA_PATH_5_4="/Users/[path to project]/./lua_modules/share/lua/5.4/?.lua;/Users/[path to project]/./lua_modules/share/lua/5.4/?/init.lua;/Users/[path to project]/?.lua;/Users/[path to project]/?/init.lua;" LUA_CPATH_5_4="/Users/[path to project]/lua_modules/lib/lua/5.4/?.so;" LUAROCKS_SYSCONFDIR='/usr/local/etc/luarocks' exec '/usr/local/bin/lua'  $([ "$*" ] || echo -i) "$@"

I've included mobdebug, luasockets, and other libraries in my project's rock tree.

When running ./lua from the command line, it works great, including adding -e "io.stdout:setvbuf('no')", which works as expected. I've also verified that the correct paths are loaded.

When attempting to use this in ZBS, I get this in the Output window:

Program starting as '"./lua" -e "io.stdout:setvbuf('no')" "/var/folders/hy/nzwthfvj3v732mpnwdl__qlh0000gn/T/.NVtMiS"'.
Program 'lua' started in '/Users/[path to project]' (pid: 22241).

And it freezes. When I stop the debugger, I get this:

Program stopped (pid: 22241).
Debugging session completed (traced 0 instructions).
Program completed in 74.94 seconds (pid: 22241).
Can't start debugging for '/Users/[path to project]/test/mc_keyframes.lua'. Compilation error:
Debugger connection closed

Any clues?

andrewstarks commented 3 years ago

I believe this was due to the Luarocks version of MobDebug, which was out of date and did not replace setfenv or getfenv with the Lua 5.2+ equivalents. Downloading this directly from the MobDebug GitHub repository seems to have solved my issue. Thanks!

pkulchenko commented 3 years ago

@andrewstarks, thank you for the update; I'm a bit confused though, as the Mobdebug that ships with the IDE itself supports Lua 5.4. Did you try to use a different version in your application, which created the issue?