microsoft / microsoft/vscode-cpptools
[bug] launch.json envFile not capable of variable interpolation
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
Environment
- OS and version: Windows NT x64 10.0.19045
- VS Code: 1.99.1
- C/C++ extension:
- OS and version of remote machine (if applicable): N/A
- GDB / LLDB version: N/A
Bug Summary and Steps to Reproduce
Bug Summary:
.env files don't appropriately handle variable substitution in conformance with the dotenv file spec
Initially raised as https://github.com/microsoft/vscode/issues/257570 but advised to move the issue here.
Relates to #9329
Steps to Reproduce:
- Create a blank repo and populate it with the following files:
launch.json
{ "version": "0.2.0", "configurations": [ { "name": "(msvc) Launch", "type": "cppvsdbg", "request": "launch", "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "envFile": "${workspaceFolder}/.env" } ] }.env
USER=admin EMAIL=${USER}@example.org PATH=~/project:${PATH} - Press
F5to triggerlaunch.json - Observe the following error message:
Invalid variable reference ${USER} in string: ${USER}@example.org.
Invalid variable reference ${PATH} in string: ~/project:${PATH}.
Expected behaviour
USER=adminis exported to the environmentEMAIL=admin@example.orgis exported to the environmentPATH=/home/username/project:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin(or some approximation thereof) is exported to the environment
Which would be consistent with Interpolation/Variable Substitution in dotenv files
Context
I'm trying to identify a transparent integration with conan for C++ development. One of the considerations for this is being able to update the following environment variables to allow the debugger to correctly resolve the paths to dependent libraries:
LD_LIBRARY_PATHDYLD_LIBRARY_PATHPATH
Conan achieves this currently (unrelated to VSCode) by generating a conanrun.{sh,bat,ps1} set of files that updates the environment. The idea is that one does the following:
source build/Debug/generators/conanrun.sh
cmake --presets conan-release
cmake --build conan-release
It doesn't seem like VSCode has the ability to do the first part of this with the existing file formats as part of its application launch cycle. https://github.com/conan-io/conan/issues/11042 proposes the addition of an ability to generate a conanrun.env, which could be consumed by the envFile parameter. However, as discussed in https://github.com/conan-io/conan/issues/11042#issuecomment-3105696577 and https://github.com/conan-io/conan/issues/11042#issuecomment-3109473501, the syntax/features that VSCode expects/supports seems inconsistent to what is understood to be the dotenv file schema
Debugger Configurations
Above
Debugger Logs
Above
Other Extensions
Persists after disabling all other extensions.
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue using the mentioned launch.json and .env files, then trace how the envFile parameter is processed when F5 starts the cppvsdbg configuration. Done means USER, EMAIL, and PATH substitutions are exported consistently with the stated expected behavior on the relevant platforms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, typescript, vscode
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100