lua traceback without message but with level - lua

Here is something fun:
-- file1.lua
require('./file2')
-- file2.lua
print("default:")
print(debug.traceback())
print("\n")
print("with both options:")
print(debug.traceback("prefix", 2))
print("\n")
print("nil message:")
print(debug.traceback(nil, 2))
This is what I get
default:
stack traceback:
./file2.lua:3: in main chunk
[C]: in function 'require'
file1.lua:2: in main chunk
[C]: ?
with both options:
prefix
stack traceback:
[C]: in function 'require'
file1.lua:2: in main chunk
[C]: ?
nil message:
nil
So if I want to have a level, I MUST also include a message? How do I get this to work without providing a message?

Related

ray-x/go.nvim attempt to index a boolean value

I'm trying to add ray-x/go.nvim plugin to my neovim setup.
I added the plugin in my plugins.lua
Then I'm trying to setup the plugin using require('go').setup().
Error detected while processing /home/rajkumar/.config/nvim/init.lua:
E5113: Error while calling lua chunk: /home/rajkumar/.config/nvim/lua/lsp/language_servers.lua:176: attempt to index a boolean value
stack traceback:
/home/rajkumar/.config/nvim/lua/lsp/language_servers.lua:176: in main chunk
[C]: in function 'require'
/home/rajkumar/.config/nvim/lua/lsp/init.lua:3: in main chunk
[C]: in function 'require'
/home/rajkumar/.config/nvim/init.lua:12: in main chunk
How can I fix this issue?

How to add a Lua library on VS

So I am a beginner in programming and I decided to learn Lua. I am adding a library to Lua (push: require 'push') but I am getting this error when I am running it on LOVE2D. What should I do?
Error
main.lua:1: module 'push' not found:
no field package.preload['push']
no 'push' in LOVE game directories.
no file 'push' in LOVE paths.
no file './push.lua'
no file '/usr/local/share/luajit-2.1.0-beta3/push.lua'
no file '/usr/local/share/lua/5.1/push.lua'
no file '/usr/local/share/lua/5.1/push/init.lua'
no file './push.so'
no file '/usr/local/lib/lua/5.1/push.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
Traceback
[love "callbacks.lua"]:228: in function 'handler'
[C]: in function 'require'
main.lua:1: in main chunk
[C]: in function 'require'
[C]: in function 'xpcall'
[C]: in function 'xpcall'

'end' expected near '<eof>' for map import for lua file

Error
Syntax error: main.lua:8: 'end' expected (to close 'function' at line 5) near '<eof>'
Traceback
[love "callbacks.lua"]:228: in function 'handler'
[C]: at 0x010558a810
[C]: in function 'require'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
I am getting the above error when I am trying to import a game map for my love2D game.
My code is below:
function love.load()
sti = require'lib/sti'
gameMap = sti('Maps/test_map.lua')
end
function love.draw()
gameMap:draw()
end
sti is a library which I am using to get the map into love. I learnt this from a youtube tutorial.
try looking at the function gameMap:draw, you might have forgotten an end on it

dofile works but call a stack traceback

main.lua
dofile("example.lua")
example.lua
print "Hello World"
results in:
Hello World
lua: main.lua:1: attempt to call a nil value
stack traceback:
main.lua:1: in main chunk
[C]: in ?
But I don't understand why?

Torch, testing issue - imagenet-multiGPU.torch

I am a newbies to torch. I have trainined my model according to 2 classes via this instruction https://github.com/soumith/imagenet-multiGPU.torch (number of classes is modifed) then, I wantted to test my model. These lines of codes are writen in instruction for testing:
dofile('donkey.lua')
img = testHook({loadSize}, 'test.jpg')
model = torch.load('model_10.t7')
if img:dim() == 3 then
img = img:view(1, img:size(1), img:size(2), img:size(3))
end
predictions = model:forward(img:cuda())
I got errors at the initial line of codes while I was trying to write.
When I try to write ;
th> dofile('donkey.lua')
I get these errors;
th> dofile("donkey.lua")
donkey.lua:18: attempt to index global 'opt' (a nil value)
stack traceback:
donkey.lua:18: in main chunk
[C]: in function 'dofile'
[string "_RESULT={dofile("donkey.lua")}"]:1: in main chunk
[C]: in function 'xpcall'
/home/leo/torch/install/share/lua/5.1/trepl/init.lua:651: in function 'repl'
...leo/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
[C]: at 0x00406670
I don't know what to do. Thanks for helping.
You need to run opts.lua before running donkey.lua using
th> dofile("opts.lua")
Check main.lua and make sure, you are not missing any other dependencies.

Resources