actboy168 / lua-debug

Lua Debug Adapter for Visual Studio Code
MIT License
437 stars 95 forks source link

Debugging script with lua_file_system call fails #141

Closed serg3295 closed 3 years ago

serg3295 commented 3 years ago

I am trying to debug script containing lfs.attributes() call. Directory ./tstdir is located in ${workspaceFolder}. When I run this script with lua interpreter lfs.attributes() returns 'table' as expected. But under debugger it returns nil and error message 'cannot obtain information from file './tstdir': No such file or directory'. Change ./tstdir on tstdir gives the same result. What I'm doing wrong?

To reproduce

local lfs    = require'lfs'
local srcDir = './tstdir'

local test, errmsg, lvl = lfs.attributes(srcDir)
print(test, errmsg, lvl)
if test  then
-- if lfs.attributes(srcDir) then
  if lfs.attributes(srcDir).mode == "directory" then
    print('OK!')
  end
else
  error(string.format("Cannot open directory, %s", srcDir))
end

Environment err28

Edit I have tested this script on Windows 10 with settings:

{
  "lua.debug.settings.luaVersion": "5.1",
  "lua.debug.settings.luaArch": "x86",
}

All works correctly. So, the problem is on linux only.

actboy168 commented 3 years ago

I think this is a bug of lfs.

serg3295 commented 3 years ago

Probably. Thanks.

serg3295 commented 3 years ago

As a workaround. I did set absolute path instead of relative and make new test local srcDir = '/home/serg/temp/tstdir'. In this case script works both in debugger and lua interpreter.

Edit with the "lua.debug.settings.console": "integratedTerminal" setting, the script works correctly in the debugger even with a relative path.