actboy168 / lua-debug

Lua Debug Adapter for Visual Studio Code
MIT License
435 stars 94 forks source link

"cwd" is not properly set on Linux #169

Closed hyh19962008 closed 2 years ago

hyh19962008 commented 2 years ago

When debugging on Linux, the "cwd" parameter is not properly set in launch.json. That means, whatever value the "cwd" is set, the debugger starts with "cwd" set to "~"(user's home directory), causing dofile() statements with relative path passed in your Lua script to fail.

Use the following script and start debug session to test current working directory:

-- testpwd.lua
fd = io.popen("pwd", "r")
stdout = fd:read("l")
print(stdout)

Tested on: Ubuntu 18.04 64bit Ubuntu 16.04 64bit Ubuntu 16.04 64bit Server connected with remote-SSH

Luckily, this can be fixed by manually changing "lua.debug.settings.console" from "internalConsole" to "integratedTerminal" in setting. It's strange that the value in package.json in the github repo code is set default to "integratedTerminal", while the one you download directly from VS marketplace is set to "internalConsole". Please fix it.

Best!

actboy168 commented 2 years ago

Currently lua-debug uses posix_spawn_file_actions_addchdir_np to support modifying cwd. Unfortunately posix_spawn_file_actions_addchdir_np is only supported since glibc 2.29.

So we need a fallback implementation.