Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempting to run successful build gives : ./script/env/ext/IOEx.lua:14: attempt to index global 'lfs #8

Open
tatsujb opened this issue Nov 10, 2022 · 7 comments

Comments

@tatsujb
Copy link

tatsujb commented Nov 10, 2022

First of all a quick recap of how to build on linux. I'm a linux user, I use ubuntu the commands below are a step by step to get a correct build on ubuntu but you can adapt for your distro (as for windows I'm pretty sure the build works as advertised on the readme page for you. if not you should make a windows-specific build issue.

#install dependencies (these might be named different on your linux there's a good chance if your linux is arch-based that you can simply remove all the "lib" in front of the package names and do "sudo pacman -Syu" instead of "sudo apt install" and it'll work)
sudo apt install git git-lfs build-essential cmake libfreetype-dev libluajit-5.1-dev libglew-dev libsdl2-dev libsdl2-dev liblz4-dev liblua5.1-dev -y
cd Documents/
git clone [email protected]:JoshParnell/libphx.git
git clone --recurse-submodules -j8 [email protected]:Limit-Theory-Redux/ltheory.git
mkdir -p ltheory/bin
cp libphx/ext/lib/linux64/libfmod.so libfmodstudio.so
cd ltheory/
mv bin/libfmod.so bin/libfmod.so.10
mv bin/libfmodstudio.so bin/libfmodstudio.so.10       #make fmod libs available
cp /usr/include/SDL2/* libphx/include/                #copy over all your locally installed SDL into your ltheory/libphx/include/ folder
sed -i '274d' libphx/src/Physics.cpp                  #this line crashes the linux compiler so I remove it
sed -i 's/lt64.exe/lf64r/g' configure.py              #I'm making sure the generated binary is lt64r instead of lt64.exe
export LD_LIBRARY_PATH=$(pwd)/bin python3
python3 configure.py                                  #on non-ubuntu this command will simply be "python configure.py"
python3 configure.py build                            #same it's only "python3" on ubuntu
python3 configure.py run                              #this should normally run Limit Theory but it crashes on an unintelligible Lua error.

the error I get is

Lua_PCall: Lua returned error message: ./script/env/ext/IOEx.lua:14: attempt to index global 'lfs' (a nil value)
Signal_Handler: Caught Abort
Lua Backtrace:

yes, the lua backtrace fails to show up.
I don't know how to fix this.
are there any LuaJit / Lua experts about?

@neonrust
Copy link

neonrust commented Nov 10, 2022

I don't get it. As I understand it, looking at the lua code, lfs seems to be an engine object exposed from the C code (reasoning being that its never assignedm just referenced). But grepping the entire source for "lfs" return only results in lua code... :|

@neonrust
Copy link

neonrust commented Nov 10, 2022

OR: is it something that exist in newer lua versions? Seems its use is only file-related so maybe it stands for "Lua file system"...

@neonrust
Copy link

neonrust commented Nov 10, 2022

Yes, that's it (or almost it): It's a third-party library for lua: https://lunarmodules.github.io/luafilesystem

Tried installing it using apt install lua5.2-filesystem but that didn't help. :(

LUA_PATH and LUA_CPATH is a thing... not gotten it to work though.

@neonrust
Copy link

neonrust commented Nov 10, 2022

export LUA_CPATH=/usr/lib/x86_64-linux-gnu/lua/5.1/?.so (installed by above apt).

Then, at the top of script/env/ext/IOEx I added:
lfs = require('lfs')
No idea why this doesn't exist...

Then, patched line 404 in libphx/script/ffi/libphx.lua:
local debug = __debug__ and 'd' or 'r' ('r' instead of '')
Otherwise it didn't find libphx64r.so, naturally.

Followed by patching line 10 in Main.lua:
local app = __app__ or Config.app or 'LTheory'
I assume because WIndows' file system is case insensitive.

And there be game window opened!

To instantly crash with:

  Warning: Game.SocketType is shadowing PHX.FFI.SocketType in _G
  Warning: Game.Socket is shadowing PHX.FFI.Socket in _G
Seed: 8093776391049441404ULL
Signal_Handler: Caught Memory Access Violation
Lua Backtrace:
  <native>: Create
    [Locals]
      cdata      (*temporary)     = cdata<struct Physics *()>: 0x7f6e09baa900
      function   (*temporary)     = 0x0x415ac2d8

  ./script/Game/Entities/System.lua(19): ctor
    [Upvalues]
      table      Nebula           = 0x0x400fd1c8
      table      Dust             = 0x0x400fed08
    [Locals]
      table      self             = 0x0x413ffc58
      cdata      seed             = 8093776391049441404ULL
(and a bunch more)

@dw0xaa55
Copy link

dw0xaa55 commented Nov 10, 2022

@neonrust I tried this on the original LT (not the redux) and I got a slightly different error message and I had to Ctrl-c the window to close it. And it was not rendering anything:

  Warning: Game.Socket is shadowing PHX.FFI.Socket in _G
  Warning: Game.SocketType is shadowing PHX.FFI.SocketType in _G
Seed: 9233320147878457214ULL
malloc(): invalid size (unsorted)
Signal_Handler: Caught Abort

Traceback (most recent call last):
  File "/home/dw/data/bare_code/ltheory/configure.py", line 19, in <module>
    subprocess.call(['bin/lt64r'] + sys.argv[2:])
  File "/usr/lib/python3.10/subprocess.py", line 347, in call
    return p.wait(timeout=timeout)
  File "/usr/lib/python3.10/subprocess.py", line 1204, in wait
    return self._wait(timeout=timeout)
  File "/usr/lib/python3.10/subprocess.py", line 1938, in _wait
    (pid, sts) = self._try_wait(0)
  File "/usr/lib/python3.10/subprocess.py", line 1896, in _try_wait
    (pid, sts) = os.waitpid(self.pid, wait_flags)
KeyboardInterrupt

Edit:
I also tried it on the redux version with the same result. Also running other scripts like mentioned by Josh in the Readme like for example python configure.py run script/App/CoordTest.lua throws following error:

 Warning: Game.Socket is shadowing PHX.FFI.Socket in _G
  Warning: Game.SocketType is shadowing PHX.FFI.SocketType in _G

  ERROR:
    ./script/Main.lua:39: module 'App.script/App/CoordTest.lua' not found:
        no field package.preload['App.script/App/CoordTest.lua']
        no file './App/script/App/CoordTest/lua.lua'
        no file '/usr/share/luajit-2.1.0-beta3/App/script/App/CoordTest/lua.lua'
        no file '/usr/local/share/lua/5.1/App/script/App/CoordTest/lua.lua'
        no file '/usr/local/share/lua/5.1/App/script/App/CoordTest/lua/init.lua'
        no file '/usr/share/lua/5.1/App/script/App/CoordTest/lua.lua'
        no file '/usr/share/lua/5.1/App/script/App/CoordTest/lua/init.lua'
        no file './libphx/script/App/script/App/CoordTest/lua.lua'
        no file './script/App/script/App/CoordTest/lua.lua'
        no file './script/App/script/App/CoordTest/lua.ext.lua'
        no file './script/App/script/App/CoordTest/lua.ffi.lua'
        no file '/usr/lib/lua/5.1/App/script/App/CoordTest/lua.so'
        no file '/usr/lib/lua/5.1/App.so'

  script.env.env.lua
      8   | function Env.Call (fn)
  --> 9   |   local _, err = xpcall(fn, ErrorHandler)
      10  |   if err then print(err) end

@neonrust
Copy link

neonrust commented Nov 10, 2022

Yeah, should've mentioned I'm on redux.

To run scripts you specify its name without path or extension, e.g. CoordTest (the ones in script/App). It's mentioned in the README.

I got these to run, seemingly problem-free:

  • BSPTest
  • CoordTest
  • TestHmGui

Well, problem-free as in: it doesn't immediately crash...

The others crash in various ways.

@dgavedissian
Copy link

dgavedissian commented Dec 8, 2022

We just merged a fix to the lfs issue in the Redux fork: https://github.com/Limit-Theory-Redux/ltheory

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

No branches or pull requests

4 participants