Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use environment variables in VS Code launch configurations

This question is related to this question about conda, and it is pretty straightforward:

How can I use an external environment variable inside launch.json?

For instance, selecting the python executable inside my home with $HOME, or the executable:

    {
        "name": "Python: From Home",
        "type": "python",
        "request": "launch",
        "program": "$HOME/Documents/a.py", // nor does "${HOME}" work
        "console": "internalConsole",
        "cwd": "${workspaceFolder}"
    }

or

    {
        "name": "Python: With Anaconda",
        "type": "python",
        "request": "launch",
        "program": "${file}",
        "console": "internalConsole",
        "python": "${HOME}/anaconda3/bin/python3",
        "cwd": "${workspaceFolder}"
    }

This would simplify sharing launch.json with coworkers.

like image 243
senseiwa Avatar asked Mar 14 '26 00:03

senseiwa


1 Answers

You can use Environment variables

The syntax is like ${env:USERNAME}

like image 142
rioV8 Avatar answered Mar 16 '26 13:03

rioV8