VS Code Debugging launch.json - Use `envFile` values in `env`

Viewed 1605

When debugging some python code in VSCode I would like for developers to be able to create a simple small envFile that looks something like...

AD_USR=username
AD_PSW=password

so those values can later be substituted into multiple other environment variables.

I tried to do something like below (note how the env vars are attempting to to consume the environment variables that were set in the envFile).

This does not work.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug My Program",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/venv/bin/thingtorun",
            "console": "integratedTerminal",
            "envFile": "${workspaceFolder}/bin/.envFile",
            "env": {
                "SYSTEM_A_USER": "${env.AD_USR}",
                "SYSTEM_A_PASSWORD": "${env.AD_PSW}",
                "SYSTEM_B_USER": "${env.AD_USR}",
                "SYSTEM_B_PASSWORD": "${env.AD_PSW}",
                ... + lots of other systems ...
            }
        }
    ]
}

Does anyone know of a mechnism of doing this?

My main objective is to avoid new developers having to create a huge envFile repeating their username and password for every system. In prod the usernames and password will vary so I cannot eliminate the need for SYSTEM_X_USER/PASSWORD either.

0 Answers
Related