Sublime Text FormatLua Error - lua

I'm trying to format code with a package I installed for Sublime Text 3 - FormatLua.
However, I'm getting this error when I try to use it...
/usr/local/bin/lua: ./metalua/compiler.lua:119:
./metalua/compiler/bytecode/lopcodes.lua:284: attempt to call field
'gfind' (a nil value) stack traceback:
[C]: in function 'error'
./metalua/compiler.lua:119: in function 'get_bytecode_compiler'
./metalua/compiler.lua:125: in function 'f'
./metalua/compiler.lua:153: in function <./metalua/compiler.lua:150>
(...tail calls...)
[C]: in function 'require'
formatter.lua:24: in main chunk
[C]: in ?
Does anyone know what I must do to fix this issue? I must be missing some files - I see that gfind is nil (this was taken out after 5.0), but I don't want to mess with anything unless I'm sure I know what I'm doing. Thanks!

Yes, gfind was deprecated. You can replace string.gfind with string.gmatch. I applied a similar change for the same reason; here is the commit.

Works well after downgrading lua version to 5.1.4
Compiling from source code:
Lua 5.1.4 here: http://www.lua.org/ftp/lua-5.1.4.tar.gz:
Open your Terminal.app
wget http://www.lua.org/ftp/lua-5.1.4.tar.gz
tar xvzf lua-5.1.4.tar.gz
cd lua-5.1.4
make macosx
make install

Related

using a batch file to open lua love is giving error

I just started learning love and I've tried opening love with a batch file, while it does open it gives this error
Error
[love "boot.lua"]:321: No code to run
Your game might be packaged incorrectly.
Make sure main.lua is at the top level of the zip.
Traceback
[love "callbacks.lua"]:228: in function 'handler'
[C]: in function 'error'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
however when dragging the whole folder inside of love it works perfectly, does somebody know how can I fix this?
Error message
Error message indicates, that you did not set correct path to your code, so the is no code to run. It should be folder containing main.lua
Simple batch file
Place the following code to file start.bat:
#ECHO OFF
"C:\Program Files\LOVE\love.exe" "C:\path\to\game\folder"
(replace C:\path\to\game\folder with actual path to folder containing main.lua and if you have love.exe elsewhere, also replace it to the correct path)
And then, you can run your code by double-clicking the start.bat file
Some helpful links:
How to run your game
Batch file example

neovim init.lua module "lua.plguins" not found

I'm in the configuration neovim
I added the configuration file in C:\Users\wupan\AppData\Local\nvim\init.lua
require("lua.plugins")
and C:\Users\wupan\AppData\Local\nvim\lua\plugins.lua
return require('packer').startup(function()
use "wbthomason/packer.nvim"
end)
After the start-up neovim
Error detected while processing C:\Users\wupan\AppData\Local\nvim\init.lua:
E5113: Error while calling lua chunk: C:\Users\wupan\AppData\Local\nvim\init.lua:1: module 'lua.plugins' not found:
no field package.preload['lua.plugins']
no file '.\lua\plugins.lua'
no file 'C:\Users\wupan\scoop\apps\neovim\current\bin\lua\lua\plugins.lua'
no file 'C:\Users\wupan\scoop\apps\neovim\current\bin\lua\lua\plugins\init.lua'
no file '.\lua\plugins.dll'
no file 'C:\Users\wupan\scoop\apps\neovim\current\bin\lua\plugins.dll'
no file 'C:\Users\wupan\scoop\apps\neovim\current\bin\loadall.dll'
no file '.\lua.dll'
no file 'C:\Users\wupan\scoop\apps\neovim\current\bin\lua.dll'
no file 'C:\Users\wupan\scoop\apps\neovim\current\bin\loadall.dll'
stack traceback:
[C]: in function 'require'
C:\Users\wupan\AppData\Local\nvim\init.lua:1: in main chunk
Press ENTER or type command to continue
May I ask why
I tried to install Lua test the require
scoop install lua
C:\Users\wupan\code\lua\test.lua
require("hello")
C:\Users\wupan\code\lua\hello.lua
print("hello world")
There are also problems
C:\Users\wupan\scoop\apps\lua\current\lua54.exe: .\test.lua:1: module 'hello' not found:
no field package.preload['hello']
no file 'C:\Users\wupan\scoop\apps\lua\current'
no file 'C:\Users\wupan\scoop\apps\lua\current'
stack traceback:
[C]: in function 'require'
.\test.lua:1: in main chunk
[C]: in ?
Problem analysis
Let's use the following example which you gave us:
C:\Users\wupan\AppData\Local\nvim\init.lua
require("lua.plugins")
C:\Users\wupan\AppData\Local\nvim\lua\plugins.lua
return require('packer').startup(function()
use "wbthomason/packer.nvim"
end)
And now let's take a look into your error message:
no file 'C:\Users\wupan\scoop\apps\neovim\current\bin\lua\lua\plugins.lua'
The important part is the bin\lua\lua thing here. It's because your
require("lua.plugins") starts to look up a directory in one of your runtime
path (see :h rtp for more information).
Solution
You just need to fix your content in
C:\Users\wupan\AppData\Local\nvim\init.lua to:
require("plugins")
because then neovim will look up a directory which is named plugins in
C:\Users\wupan\scoop\apps\neovim\current\bin\lua for example, since its in
your runtime path.
Little note
You can change your content from
C:\Users\wupan\AppData\Local\nvim\lua\plugins.lua to:
require('packer').startup(function()
use "wbthomason/packer.nvim"
end)
or how I did it:
local packer = require('packer')
packer.startup(function(use)
use 'wbthomason/packer.nvim'
end)
That makes it a little bit more readable in my opinion :)

Got `internal error in __sub: no metatable` error in Lua and Torch

I tried to create a image-to-image model by pix2pix (https://github.com/phillipi/pix2pix) and followed Getting Started instruction.
Then, downloaded facades dataset by bash ./datasets/download_dataset.sh facades
and run DATA_ROOT=./datasets/facades name=facades_generation which_direction=BtoA th train.lua
but I got the following error.
~/torch-cl/install/bin/luajit: ./models.lua:69: internal error in
__sub: no metatable stack traceback: [C]: in function '__sub' ./models.lua:69: in function 'defineG_unet' train.lua:110: in
function 'defineG' train.lua:146: in main chunk [C]: in function
'dofile'
...i/torch-cl/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in
main chunk [C]: at 0x010ec81ce0
Does anyone know how I can fix this?
I'm new to Lua and Torch, so have no idea how to fix this.
Thank you
this is run on Mac OSX
python2.7

Lua Error Loading Limlib2 Library even though it's already installed?

I have install limlib2 and everything and I've checked the directories to see if it's existent, and limlib2 is there. I compile some lua code that uses
require("limlib2")
I receive this error:
lua: error loading module 'limlib2' from file '/usr/local/lib/lua/5.3/limlib2.so':
dlopen(/usr/local/lib/lua/5.3/limlib2.so, 6): Symbol not found: _luaL_checkint
Referenced from: /usr/local/lib/lua/5.3/limlib2.so
Expected in: flat namespace
in /usr/local/lib/lua/5.3/limlib2.so
stack traceback:
[C]: in ?
[C]: in function 'require'
imgpxl.lua:1: in main chunk
[C]: in ?
Any help? I don't understand what's going on.
limlib2 is referencing _luaL_checkint which fails in Lua 5.3 as _luaL_checkint has been replaced by _luaL_checkinteger in Lua 5.2
_luaL_checkint is deprecated. Just google for _luaL_checkint to find plenty of workarounds.
Checkout this: Cannot make gunplot on osx yosemite. Undefined symbols
imlib2 seems to haven't been updated in over 8 years. So no wonder you're facing problems

Error in running Torch/Lua, maybe an installation error

I installed Torch following http://torch.ch/docs/getting-started.html.
However, when I run things like "th" or any simple code, I got the following error message:
/Users/JianxuChen/torch/install/bin/luajit: ...rs/JianxuChen/torch/install/share/lua/5.1/trepl/init.lua:692: attempt to call field 'setheaptracking' (a nil value)
stack traceback:
...rs/JianxuChen/torch/install/share/lua/5.1/trepl/init.lua:692: in main chunk
[C]: in function 'require'
...Chen/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:104: in main chunk
[C]: at 0x01089f8bc0
Does anyone have ever encountered similar issue, or have any idea about how to solve it?
Thanks!
I met the same problem and solved it in this way. Your torch is not the latest version. What I do is NOT follow this http://torch.ch/docs/getting-started.html. Instead download https://github.com/torch/distro and run ./install. Then it works!

Resources