Repository navigation
[bug] launch.json envFile not capable of variable interpolation #13781
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 microsoft/vscode#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-releaseIt 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. conan-io/conan#11042 proposes the addition of an ability to generate a conanrun.env, which could be consumed by the envFile parameter. However, as discussed in conan-io/conan#11042 (comment) and conan-io/conan#11042 (comment), the syntax/features that VSCode expects/supports seems inconsistent to what is understood to be the dotenv file schema
Debugger Configurations
AboveDebugger Logs
AboveOther Extensions
Persists after disabling all other extensions.
Additional Information
No response
Activity
[-]launch.json envFile not capable of variable interpolation[/-][+][bug] launch.json envFile not capable of variable interpolation[/+]