Search code examples
macosdebuggingluapremakezerobrane

How to debug Premake5 with ZeroBrane


I'm having problems while trying to debug Premake5 (https://github.com/premake/premake-core) on macOS Sierra 10.12, using ZeroBrane

I've added the package.cpath and package.path (before calling require('mobdebug').start()) as described in ZeroBrane documentation, but I always have the same error:

Error: error loading module 'socket.core' from file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/socket/core.dylib':
    file is not a bundle

Or, if I re-compile Lua with LUA_USE_DLOPEN I get a different error:

Error: error loading module 'socket.core' from file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs/socket/core.dylib':
    dlopen(/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs/socket/core.dylib, 2): Symbol not found: _luaL_prepbuffsize
  Referenced from: /Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs/socket/core.dylib
  Expected in: flat namespace
 in /Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs/socket/core.dylib

Any help available?

Thanks


Solution

  • You seem to be using a version of Lua in Premake that is different from the version that luasocket libraries are compiled for. "file is not a bundle" is a Lua 5.1 message that is shown when the file loader fails to load dynamic library on MacOS with NSObjectFileImageInappropriateFile error. In this case you are loading a library compiled for Lua 5.3 from Lua 5.1 interpreter (/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/socket/core.dylib).

    In the second case you are actually loading Lua 5.1 library (/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs/socket/core.dylib), but given the error message (Symbol not found: _luaL_prepbuffsize), you seem to be loading it from Lua 5.2 or Lua 5.3 interpreter (as luaL_prefbuffsize was introduced in Lua 5.2).

    You should be able to load the module without issues as long as the interpreter you use matches the version of the module you are trying to load.