ZeroBrane Studio how to setup debugging for lua 5.4 on mac M1?

163 Views Asked by At

As in the title. How to setup ZeroBrane Studio to work (run and debug scripts) lua 5.4 on mac with M1 chip. I'm mainly after debugging capabilities.

Documentation https://studio.zerobrane.com/doc-lua54-debugging seems to describe (kinda) how to configure it on Windows...

Any links, suggestions where to look for more info about above question?


Story behind (Off-topic/Digression):

Originally I've started working with VScode ... but there are some issues with that too: How to debug Lua 5.4 on VScode?

So from that point I've started looking for alternatives and on Hacker News I found that generally ZeroBrane Studio seems to be popular but it also works with 5.3...

... It's kinda hard to be up to date with Lua I found, and it's even worse for beginner like me.

---- EDIT after @paul-kulchenko response --- vvvv

Yep that seems to help but I still stuck debugging simple script:

require('mobdebug').start()

print(_VERSION)

on error:

enter image description here

it seems to be somewhere here: enter image description here

----- EDIT after further attempts to make it work

It started to work after replacing local file

/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs/mobdebug/mobdebug.lua

with

https://github.com/pkulchenko/ZeroBraneStudio/blob/e91ed23c25a65f780faa5de061f2ed9cdfe2d1bd/lualibs/mobdebug/mobdebug.lua

but I would much more prefer to have already baked app than doing all this.

Thank you anyway @paul-kulchenko

--- EDIT: FINAL PROCEDURE

# installation
1) 
    Install app from https://studio.zerobrane.com/download?not-this-time
    at the moment of creating this tutorial it is: ZeroBrane Studio (1.90; MobDebug 0.803)
    WARNING: RUN THE APP NOW - that's important for further steps
2)
    Run script:
            
export APPDIR="/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio"
cd "$(mktemp -d)"
git clone [email protected]:pkulchenko/ZeroBraneStudio.git .
git checkout 996e99a6ee28f89f25913b955fa4144688ae6e73
    # latest commit (as of 2023-06-25) of branch: https://github.com/pkulchenko/ZeroBraneStudio/commits/master
    # mentioned in https://github.com/pkulchenko/ZeroBraneStudio/issues/1075 and https://stackoverflow.com/a/76548375
    # actually NO, lua54 branch is mentioned but we have to use master branch
(cd build; bash ./build-macosx.sh lua 5.4 luasocket) | tee _build.log   
    # expected message >*** Build has been successfully completed ***<
      
cat <<EEE > "./interpreters/luadeb54.lua"
dofile 'interpreters/luabase.lua'
local interpreter = MakeLuaInterpreter(5.4, ' 5.4')
interpreter.skipcompile = true
return interpreter            
EEE
    # from https://stackoverflow.com/a/76548375 

            
open ./bin
open "${APPDIR}/bin"
  # and copy manually
mv clibs54 "${APPDIR}/bin/"
mv lua54 "${APPDIR}/bin/"
mv liblua54.dylib "${APPDIR}/bin/"

open ./interpreters   
open "${APPDIR}/interpreters"  
  # then copy manually between these two directories
interpreters/luadeb54.lua

open ./lualibs/mobdebug   
open "${APPDIR}/lualibs/mobdebug"          
  # REPLACE manually mobdebug.lua    
          
# app should be ready to run now

# after running the app
# choose from menu 
#     Project -> Lua Interpreter -> Lua 5.4
            
          
1

There are 1 best solutions below

0
Paul Kulchenko On

Even though Lua 5.4 is not packaged with the IDE itself, it should be possible to debug Lua 5.4 applications as long as you have the interpreter and luasocket module compiled for Lua 5.4.

If you do want to load it directly from the IDE, then you should be able to compile them on macOS using the build scripts provided with the IDE. You can get the latest master branch from the repository and run the following command: (cd build; bash ./build-macosx.sh lua 5.4 luasocket). This should build Lua 5.4.6 interpreter and luasocket library and put them in the correct location for the IDE to use.

You can then add Lua 5.4 interpreter (the code is available here) and you should see the Lua5.4 interpreter from the IDE to use with your scripts/applications. If you run into any issues, feel free to comment in the ticket for Lua 5.4 work.

[Updated 9/2/23] The new release v2.0 includes Lua 5.4 interpreter and other modules linked with Lua 5.4.