Repository navigation
Cannot debug on MacOS when long environment variable is set (circa 2000 characters) #6874
Description
Type: Debugger
Describe the bug
- OS and Version: MacOS 10.15
- VS Code Version: 1.52.1
- C/C++ Extension Version: 1.1.3
- Other extensions you installed (and if the issue persists after disabling them): issue persists after disabling every other extension
- A clear and concise description of what the bug is.
First of all thank you for the great product! 💯 👍 !!!!
To Reproduce
Please include a code sample and launch.json configuration.
Steps to reproduce the behavior:
- Create a .env file with a long environment variable. See attached file. envfile.txt
- Add a launch.json using the .env file that runs any executable. See example launch.json.txt
- Launch entry
- See regrettable error message pop up on screen

Additional context
Problem occurs even if I set the environment directly in the configuration. It appears that the message is truncated on its way to the underlying engine.
The issue goes away if I remove one character from the attached envFile.
According to DevToolsSecurity -status, Developer mode is currently enabled.
Debug Console output:
`--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (327) <-1008-interpreter-exec console "settings set target.env-vars DYLD_LIBRARY_PATH=\"/Users/vagrant/builds/ninja-release/conan-home/.conan/data/lexactivator/3.12.1///package/98693e2cd8e6a5b0612dd5b0ae31d688615da5b9/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/lexfloatclient/4.3.10///package/98693e2cd8e6a5b0612dd5b0ae31d688615da5b9/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/openscenegraph/3.6.3///package/496c694a158600e9374d6f4ff119717cb4329963/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/cryptopp/8.2.0/bincrafters/stable/package/65b4eeac84096d8cf1459a798c07440f6ed79e3a/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/ccdcsqlite3/3.17.0///package/863dc29f74a5b1da8915b98a222bbcc45e90ce46/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/gtest/1.8.1///package/89353b6e006c1d513020e00f56b6b24bd8163e5d/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/gsoap/2.8.109///package/4bca0050b2fbb691fd93ec5a87cdc464b4cbf097/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/libxl/3.8.2.0///package/fbc9f5348579d8c9e4ba5a008d95280b87ce1e8a/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/inchi/1.04///package/4968af75f822d4742c208cdc37bfd4618fba68cd/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/rstatistics/2.11.1///package/743cf0321be3152777da4d05247a66d1552e70a2/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/csdprotobufs/1.0.117///package/b09b1606af513081c72c033281d3a8b666c2bc74/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/mariadb-connector-c/3.1.11///package/e5367c0e9e837dbe471cdcb23927a9ee1c3a2150/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/pcre/8.41///package/01ffead025ec90a93de23fa980552b4c33618f62/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/openssl/1.1.1i///package/4968af75f822d4742c208cdc37bfd4618fba68cd/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/libxml2/2.9.10///ssssssss\""\n"},"seq":76}
1: (327) <-1008-interpreter-exec console "settings set target.env-vars DYLD_LIBRARY_PATH="/Users/vagrant/builds/ninja-release/conan-home/.conan/data/lexactivator/3.12.1///package/98693e2cd8e6a5b0612dd5b0ae31d688615da5b9/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/lexfloatclient/4.3.10///package/98693e2cd8e6a5b0612dd5b0ae31d688615da5b9/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/openscenegraph/3.6.3///package/496c694a158600e9374d6f4ff119717cb4329963/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/cryptopp/8.2.0/bincrafters/stable/package/65b4eeac84096d8cf1459a798c07440f6ed79e3a/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/ccdcsqlite3/3.17.0///package/863dc29f74a5b1da8915b98a222bbcc45e90ce46/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/gtest/1.8.1///package/89353b6e006c1d513020e00f56b6b24bd8163e5d/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/gsoap/2.8.109///package/4bca0050b2fbb691fd93ec5a87cdc464b4cbf097/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/libxl/3.8.2.0///package/fbc9f5348579d8c9e4ba5a008d95280b87ce1e8a/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/inchi/1.04///package/4968af75f822d4742c208cdc37bfd4618fba68cd/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/rstatistics/2.11.1///package/743cf0321be3152777da4d05247a66d1552e70a2/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/csdprotobufs/1.0.117///package/b09b1606af513081c72c033281d3a8b666c2bc74/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/mariadb-connector-c/3.1.11///package/e5367c0e9e837dbe471cdcb23927a9ee1c3a2150/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/pcre/8.41///package/01ffead025ec90a93de23fa980552b4c33618f62/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/openssl/1.1.1i///package/4968af75f822d4742c208cdc37bfd4618fba68cd/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/libxml2/2.9.10///ssssssss""
1: (328) STDERR: MI: Error: Command Args. Validation failed. Mandatory args not found: interpreter, command. Not all arguments or options were recognised: console "settings set target.env-vars DYLD_LIBRARY_PATH="/Users/vagrant/builds/ninja-release/conan-home/.conan/data/lexactivator/3.12.1///package/98693e2cd8e6a5b0612dd5b0ae31d688615da5b9/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/lexfloatclient/4.3.10///package/98693e2cd8e6a5b0612dd5b0ae31d688615da5b9/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/openscenegraph/3.6.3///package/496c694a158600e9374d6f4ff119717cb4329963/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/cryptopp/8.2.0/bincrafters/stable/package/65b4eeac84096d8cf1459a798c07440f6ed79e3a/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/ccdcsqlite3/3.17.0///package/863dc29f74a5b1da8915b98a222bbcc45e90ce46/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/gtest/1.8.1///package/89353b6e006c1d513020e00f56b6b24bd8163e5d/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/gsoap/2.8.109///package/4bca0050b2fbb691fd93ec5a87cdc464b4cbf097/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/libxl/3.8.2.0///package/fbc9f5348579d8c9e4ba5a008d95280b87ce1e8a/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/inchi/1.04///package/4968af75f822d4742c208cdc37bfd4618fba68cd/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/rstatistics/2.11.1///package/743cf0321be3152777da4d05247a66d1552e70a2/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/csdprotobufs/1.0.117///package/b09b1606af513081c72c033281d3a8b666c2bc74/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/mariadb-connector-c/3.1.11///package/e5367c0e9e837dbe471cdcb23927a9ee1c3a2150/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/pcre/8.41///package/01ffead025ec90a93de23fa980552b4c33618f62/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/openssl/1.1.1i///package/4968af75f822d4742c208cdc37bfd4618fba68cd/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/libxml2/2.9.10///ssssssss"`
Hopefully this might be of assistance
--> E (output): {"type":"event","event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/DebugCompleted","data":{"VS.Diagnostics.Debugger.ImplementationName":"Microsoft.MIDebugEngine","VS.Diagnostics.Debugger.EngineVersion":"16.5.11030.1","VS.Diagnostics.Debugger.HostVersion":"16.5.11030.1","VS.Diagnostics.Debugger.AdapterId":"cppdbg","VS.Diagnostics.Debugger.DebugCompleted.BreakCounter":0}},"seq":111}
Activity
thirtytwobits commentedon Jan 30, 2021
I'm seeing this on OSX using lldb but it's not length it's escaping. The environment variables can, apparently, contain some text that is not properly escaped when invoking lldb. By clearing my environment it seems to work:
rockdreamer commentedon Jan 31, 2021
Hi Scott, I'm not sure the behaviour you're seeing is the same issue. That would conflict with two facts:
I can see how string escaping might be an issue in it's own right, there's very little in the way of public documentation of dotenv files. I think we'll both be better served if you create a separate bug report with a more specific test case, mentioning the specific characters that are creating the issue for you. (I'm sure it will open a nasty can of worms, requiring - gasp! - developers of multiple IDEs communicate amongst themselves :) )
WardenGnaw commentedon Feb 3, 2021
Do you have
externalConsole: truein yourlaunch.json?I couldn't find it at the moment, but I'll see if I can later, but I believe
lldb-mitries to pass all the env variables as a command line, so it is limited to the terminal input's limitation.rockdreamer commentedon Feb 3, 2021
Hi Andrew Wang (@WardenGnaw), thank you for looking into this.
I just tried and I get the same outcome with externalConsole set to either true or false.
I wondered if there were settings set that might affect this but this is all I have in
$HOME/Library/Application Support/Code/User/settings.jsongithub-actions commentedon Aug 3, 2021
This issue has been closed automatically because it has not had recent activity.
rockdreamer commentedon Aug 3, 2021
Crickets...
felipeek commentedon Nov 12, 2021
I'm having the exact same issue!
felipeek commentedon Nov 12, 2021
Andrew Wang (@WardenGnaw) can you please re-open this bug? The issue is still there and it is very easy to reproduce. The debugger is not usable when the environment array is too long
Fix passing long environment variables to de debugger
Fix passing long environment variables to the debugger
ylatuya commentedon Nov 23, 2021
I stumbled into the same issue and following Andrew Wang (@WardenGnaw) I created a new PR that fixes the issue: lldb-tools/lldb-mi#87
To test it, follow the instructions to build lldb-mi from https://github.com/lldb-tools/lldb-mi#building-against-custom-lldb and add to your
launch.json"miDebuggerPath": "/path/to/lldb-mi/build/src/lldb-mi"Fix passing long environment variables to the debugger
Fix passing long environment variables to the debugger
Fix passing long environment variables to the debugger (#87)
Bump lldb-mi commit hash
ylatuya commentedon Oct 23, 2023
This issue should be reopened, since in order to fix it, it requires an lldb-mi hash bump to include the fix in lldb-tools/lldb-mi#87
Bump lldb-mi commit hash
github-actions commentedon Apr 21, 2024
This issue has been closed as lower priority. We're sorry if this issue still impacts you but unfortunately we're not able to address this. We will accept a pull request from the community if it's applicable for this issue.
H-G-Hristov commentedon Sep 23, 2025
Can we get this fixed finally?
Bump lldb-mi commit hash
Bump lldb-mi commit hash