As of macOS Monterey 12.2.1 and Visual Studio Code 1.66.0.
The value of macOS's PATH
environment variable is set or modified by many different processes. By the time you run programs from the integrated terminal in Visual Studio Code, it's changed several times. Running a task or launching an extension in VS Code makes it even more complicated. Let's take a look.
On macOS, each process after booting is started by another process. When creating the "child" process, the "parent" process can choose what environment the child process starts with. Most programs either allow their child processes to "inherit" the same process they started with or start their child processes with "clean" environments with relatively few environment variables set, but nearly any customization of the environment is possible for each child process.