Doesn't pass environment variables
Function getenv("HOME") returns empty string when application is launched via target debugging.
CMakeTools 0.7.4 (it worked on 0.7.3) VSCode 1.7.1
I'm not able to reproduce the issue. Do you have anything in your debugConfig?
Platform: OSX, llvm 3.9.0 I have a such settings only: { "cmake.buildDirectory": "${workspaceRoot}/../build", "cmake.experimental.enableTargetDebugging": true }
So, this is what I have investigated at the moment.
- Running the target without "debugConfig" generates default launch configuration. This configuration is launched with empty environment. May be, because of absence of "environment" variable, needed for "cppdbg". But I am using other debugger.
- But the main problem for me is not well formed (for 0.7.4) debugConfig string
Instead of:
"cmake.debugConfig": { "all": { "request": "launch", "type": "lldb", "env": {"QT_PLUGIN_PATH": "/Users/admin/Qt/5.5/clang_64/plugins"} } }
I should use:
"cmake.debugConfig": { "request": "launch", "type": "lldb", "env": {"DYLD_IMAGE_SUFFIX": "_debug"} }
At the moment, I've only got in support for the cpptools debugging engine from Microsoft, which wants environment variables in environment rather than env, and they are passed in a different format (a list of objects rather than a single object of key-value paris). Are you trying to use a different debugger?
Also, yes. I did change the format of the debugConfig.
Yes, I am using "LLDB Debugger" extension. It works for me after fixing my debugConfig. But default debug configuration (cppdbg) is still launched with missing environment variables.
I should probably make it clearer that target debugging is specifically written against cpptools. So, if you fix up the debugConfig, is it all working well?
It doesn't work correctly for cppdbg (lose system environment variables) and works for lldb. Note, that lldb - is debugger extension for cpptools.
FWIW I have this exact same issue on macOS (but it works fine in Linux).
I was able to work around it by setting "externalConsole": true in my "cmake.debugConfig": { } settings section. Not ideal, maybe, but it did fix the problem for me.
It's been a while, but has anyone tried using the ${command:cmake.debugTargetProgramPath} substitution in their launch.json?
@vector-of-bool are there instructions for doing this? I don't quite understand what this means, but can give it a shot next time I'm debugging on my mac if there are more setup details.
Not quite. The substitution behavior is documented, but not often used.
Basically, for any value in launch.json, you can put ${command:<some-command>} and VSCode will call <some-command> to replace the value. This means that you can put ${command:cmake.debugTargetProgramPath} in place of the path to the executable, and VSCode will use that command to ask CMake Tools for the path to the executable.
@clangen Please find sample launch.json in the PR above, if you're still interested.
@ytimenkov thanks for the updated documentation. Unfortunately the suggestion to use a custom launch.json did not solve my particular issue -- I'm still unable to resolve environment variables (e.g. $HOME) unless I force the app to run in an external console.
Maybe issue is in cpp extension or VS code itself, or specific to Mac. Works on my Windows machine. It might help if you provide VS version info (Click on smiley in the bottom-right corner of VS Code, then "Submit bug" and copy/paste here).
Sure. Everything should be up to date, and I have very few extensions installed:
- VSCode Version: Code 1.13.0 (376c52b955428d205459bea6619fc161fc8faacf, 2017-06-08T16:34:53.678Z)
- OS Version: Darwin x64 16.6.0
- Extensions:
| Extension | Author | Version |
|---|---|---|
| autotrim | NathanRidley | 1.0.6 |
| cpptools | ms-vscode | 0.11.4 |
| cmake | twxs | 0.0.17 |
| cmake-tools | vector-of-bool | 0.9.7 |
Closed. If this issues still persists in the current 0.11.0-beta4, feel free to reopen this one or create a new one.