actboy168 / lua-debug

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

cannot open folder: Permission denied #277

Closed roie-r closed 1 year ago

roie-r commented 1 year ago

I've a folder with a collection of unrelated scripts. I used to be able to debug any open file with just F5 - without changes in launch.json. After a recent update, I need a file's full path: "program": "${workspaceFolder}/tests/01.lua" to the launch the debugger, else I get: cannot open C:\lua_scripts_collection: Permission denied Which means editing launch.json every time I need to debug a different script. Is there any way to solve that?

actboy168 commented 1 year ago

Can you provide a reproducible example?

roie-r commented 1 year ago

It's perfectly persistent on my end: New folder: D:\luas New files: D:\luas\1.lua & D:\luas\2.lua. Both files contain...

for i=1, 10 do
  print(i) -- break point
end

When launching the debugger, this is the default launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "lua",
      "request": "launch",
      "name": "Debug",
      "program": "${workspaceFolder}/1.lua"
    }
  ]
}

Terminal output is: PS D:\luas> & 'c:/Users/roier/.vscode/extensions/actboy168.lua-debug-2.0.3-win32-x64/runtime/win32-x64/lua54/lua.exe' '-e' 'dofile[[c:/Users/roier/.vscode/extensions/actboy168.lua-debug-2.0.3-win32-x64/script/launch.lua]];DBG[[5736-ansi]]' 'D:\luas/1.lua' 1 2 3 ... all is well.

However, if I want to debug 2.lua I need to edit launch.json to "program": "${workspaceFolder}/2.lua" !

If I edit launch.json to just the workspace: "program": "${workspaceFolder}", terminal output is: PS D:\luas> d:; cd 'd:\luas'; & 'c:/Users/roier/.vscode/extensions/actboy168.lua-debug-2.0.3-win32-x64/runtime/win32-x64/lua54/lua.exe' '-e' 'dofile[[c:/Users/roier/.vscode/extensions/actboy168.lua-debug-2.0.3-win32-x64/script/launch.lua]];DBG[[12076-ansi]]' 'D:\luas/' C:\Users\roier.vscode\extensions\actboy168.lua-debug-2.0.3-win32-x64\runtime\win32-x64\lua54\lua.exe: cannot open D:\luas/: Permission denied ... The debugger stops immediately after launch.

This wasn't the case until recently. I've been using this extension for a long while (thank you for this tool BTW), and used to be able to launch the debugger for any file in the workspace without editing the launch json.

actboy168 commented 1 year ago

I don't know how you could have worked correctly before. But this is always wrong. You should use:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "lua",
      "request": "launch",
      "name": "Debug",
      "program": "${file}"
    }
  ]
}
roie-r commented 1 year ago

That works. Thank you. As I said, it was the default. I even check an backup from months ago and "${workspaceFolder}" is there too. A minor mystery, what can I say.