Set global $PATH environment variable in VS Code

If you only need the $PATH to be set in the integrated terminal, you can use VS Code's terminal.integrated.env.<platform> variable (added in version 1.15). Press Cmd+Shift+P (or Ctrl+Shift+P) and search for "Preferences: Open Settings (JSON)". Then add the following entry to the settings file:

"terminal.integrated.env.osx": {
  "PATH": "...:/usr/bin:/bin:..."
}

(Replace .osx with .linux or .windows as needed.)

To see your system's $PATH, type echo "$PATH" in Terminal.app, and copy and paste it into the settings snippet above.


As for having the $PATH available everwhere in VS Code, so that it will be used by extensions that call binaries, the only workaround I've found so far is this:

  1. Configure your shell (bash by default) to have the $PATH you want. For example, my ~/.bash_profile has the following line:

    PATH="$PATH:$HOME/bin"
    
  2. In VS Code, press ⇧⌘P and type install 'code' command if you haven't done so before.

  3. Quit VS Code.

  4. Launch VS Code not by clicking the icon in the dock or in Launchpad, but by opening Terminal.app and typing code. Your newly set path will be active in VS Code until you quit it.

  5. If VS Code restarts, for example due to an upgrade, the $PATH will reset to the system default. In that case, quit VS Code and re-launch it by typing code.


In:

> Preferences: Open Settings (JSON)

add to the JSON file:

"terminal.integrated.env.windows": {
    "PATH": "${env:PATH}"
},

-> terminal.integrated.env should end with .osx, .linux or .windows depending on your OS.


In order to check if it works execute in your VS Code Terminal:

# For PowerShell
echo $env:PATH
# For bash
echo "$PATH"

I am using vscode on macos for C/C++ development in conjunction with CMake.

The vscode extension CMake Tools allows to manipulate environment variables via the configuration properties cmake.configureEnvironment, cmake.buildEnvironment and cmake.environment (acting respectively on the CMake configuration phase, the build phase and both - see docs).

Then you can extend your system PATH with custom paths by adding the following snippet to your user or project settings.json:

"cmake.environment": {
    "PATH": "~/.myTool/bin:${env:PATH}"
},