It seems you tried to enter this

terminal.integrated.env.linux

into the terminal prompt itself, which treated it as a literal command.

What that guide on PYTHONPATH meant when it said "through the terminal settings" was Visual Studio Code's Integrated Terminal settings: https://code.visualstudio.com/docs/getstarted/settings. Specifically the settings under Terminal (filtered on terminal.integrated.env):

Depending on your OS/platform, you put a terminal.integrated.env.<os> block in your VS Code's settings.json file to specify the environment variables to inject when using VS Code's integrated terminal:

From https://code.visualstudio.com/docs/getstarted/settings#_default-settings:

// Object with environment variables that will be added to the
// VS Code process to be used by the terminal on Linux. Set to  
// `null` to delete the environment variable.
"terminal.integrated.env.linux": {},

So if you are on Linux:

"terminal.integrated.env.linux": {
  "PYTHONPATH": "<absolute path>"
},

Note: see the Python docs on PYTHONPATH on what exactly needs to be specified here.

Or, as the guide says, you can also specify a .env file.

Answer from Gino Mempin on Stack Overflow
🌐
Visual Studio Code
code.visualstudio.com › docs › terminal › profiles
Terminal Profiles
November 3, 2021 - This can be configured for all profiles using the terminal.integrated.env.<platform> setting.
Discussions

visual studio code - terminal.integrated.env.windows for Integrated Terminal - Stack Overflow
Finally, yume-chan answer by question in Ref: https://github.com/Microsoft/vscode/issues/34420#issuecomment-329705397 More on stackoverflow.com
🌐 stackoverflow.com
How can I globally set the PATH environment variable in VS Code? - Stack Overflow
Hm, my $SHELL is /usr/local/bin/bash ... lastest VSCODE yet it's not running .bash_profile so far as I can tell. ... I'm having problems I suspect are related to this, but I can't verify if my fixes are working or are unneeded because I can't work out how to access process.env.PATH. Can you explain? ... If you only need the $PATH to be set in the integrated terminal, you can use ... More on stackoverflow.com
🌐 stackoverflow.com
Setting of terminal.integrated.env.windows do not works in the new version
Does this issue occur when all extensions are disabled?: Yes VS Code Version: 1.65.0 OS Version: Windows 10 Steps to Reproduce: In the new version (1.65.0) the Visual Code lost the configuration of "terminal.integrated.env.windows". I us... More on github.com
🌐 github.com
2
March 4, 2022
Usage of terminal.integrated.env is now showing 'Do you allow this workspace to modify your terminal shell? env' info message
Usage of terminal.integrated.env is now showing 'Do you allow this workspace to modify your terminal shell? env' info message#68032 ... *as-designedDescribed behavior is as designedDescribed behavior is as designedterminalGeneral terminal issues that don't fall under another labelGeneral terminal issues that don't fall under another label ... Our extension sets some environment variables in .vscode... More on github.com
🌐 github.com
11
February 7, 2019
🌐
Visual Studio Code
code.visualstudio.com › docs › python › environments
Python environments in VS Code
November 3, 2021 - Create a .env file in your workspace root or specify a custom path with python.envFile ... Variables are injected when terminals are created.
🌐
Serkanh
serkanh.github.io › vscode,terminal, › 2018 › 10 › 15 › set-up-vscode-terminal-env-var.html
Setup env variables for VScode integrated terminal.
October 15, 2018 - In order to do it you need to setup env var AWS_PROFILE on the current shell session. So in order to that in vscode simply create .vscode/settings.json in your projects root and append or add the following snippet. Depending on the os you might need to slightly use different settings. { "terminal.integrated.env.osx": { "AWS_PROFILE":"shaytacycombinator" } }
Find elsewhere
Top answer
1 of 13
128

If you only need the $PATH to be set in the integrated terminal, you can use VS Code's terminal.integrated.env.<platform> setting (added in version 1.15). Find the setting for your platform in the settings, click "Edit in settings.json", and add a "PATH" field like so:

"terminal.integrated.env.osx": {
  "PATH": "${env:PATH}:/my/path"
}

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

The expression ${env:PATH} causes the existing contents of the $PATH environment variable to be inserted. This way you can extend it without hard-coding it.


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 to have the $PATH you want. For example, I'm using Bash, and 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 its icon in the dock, 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.

Update: VS Code on Mac and Linux now apparently tries to automatically resolve the shell environment when it is started by clicking the icon (rather than via code). It does this by temporarily starting a shell and reading the environment variables. I haven't tested this though.

2 of 13
38

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"
🌐
Visual Studio Code
code.visualstudio.com › docs › terminal › basics
Terminal Basics
November 3, 2021 - Visual Studio Code has an integrated terminal to enable working in your shell of choice without leaving the editor.
🌐
GitHub
github.com › microsoft › vscode › issues › 144391
Setting of terminal.integrated.env.windows do not works in the new version · Issue #144391 · microsoft/vscode
March 4, 2022 - "terminal.integrated.env.windows": { "Path": "${env:PATH};C:/Development/SW/sonar-scanner/bin/;C:/Development/SW/terraform;" }
Author   fkfouri
🌐
Visual Studio Code
code.visualstudio.com › docs › terminal › advanced
Terminal Advanced
November 3, 2021 - The process environment of the application running within the terminal is influenced by various settings and extensions and can cause the output in the VS Code terminal to look different than in other terminals. When VS Code is opened, it launches a login shell environment in order to source a shell environment.
🌐
Visual Studio Code
code.visualstudio.com › remote › advancedcontainers › environment-variables
Environment variables
November 3, 2021 - Build and test web apps with the integrated browser and AI agents. ... You can set environment variables in your container without altering the container image by using one of the options below. You should verify Terminal > Integrated: Inherit Env is checked in settings or the variables you ...
🌐
GitHub
github.com › microsoft › vscode › issues › 68032
Usage of terminal.integrated.env is now showing 'Do you allow this workspace to modify your terminal shell? env' info message · Issue #68032 · microsoft/vscode
February 7, 2019 - Usage of terminal.integrated.env is now showing 'Do you allow this workspace to modify your terminal shell? env' info message#68032 ... *as-designedDescribed behavior is as designedDescribed behavior is as designedterminalGeneral terminal issues that don't fall under another labelGeneral terminal issues that don't fall under another label ... Our extension sets some environment variables in .vscode/settings.json by using terminal.integrated.env.{platform}. In the latest version of vscode & vscode insiders this is now showing the users an info message asking them to allow/disallow these configurations.
Author   lcampos
🌐
Reddit
reddit.com › r/vscode › vscode launched from terminal and environment variables
r/vscode on Reddit: VSCode launched from terminal and environment variables
October 28, 2025 -

My OS is Windows and I usually work with cmake-based C projects. The compiler isn't always the same, it generally changes for each project.

I usually launch and configure the environment variables (PATH and others) of a terminal depending on the project I'm working on. I have terminal configuration for projects that need an instance of arm-gcc (installed in C:\nxp\toolchanins\... for example). Another terminal configuration for avr8-gcc and so on.

In this way cmake is able to find the correct compiler of the project (arm-gcc, avr-gcc or other) without putting any absolute path in the build configuration files (CMakeLists.txt, CMakePresets.json, ...).

I thought it was obvious to launch vscode from the same build terminal to have the same behaviour... and indeed it really works. However it works until I launch a second VSCode instance on a different compiler project. It seems the second VSCode instance inherit the same env variables from the first VSCode instance, ignoring the env variables of the terminal it was launched from.

The solution I found is to modify .vscode/settings.json, putting there the env variables needed for the workspace. In this case I need to use absolute paths, that isn't too good. And I need to specify the env variables multiple times in settings.json ("terminal.integrated.env.windows", "cmake.configureEnvironment" and so on).

Do you suggest another and better approach?

🌐
Visual Studio Code
code.visualstudio.com › docs › terminal › shell-integration
Terminal Shell Integration
November 3, 2021 - string match -q "$TERM_PROGRAM" "vscode" and . (code --locate-shell-integration-path fish) ... Add the following to your PowerShell profile. Run code $Profile in pwsh to open the file in VS Code. if ($env:TERM_PROGRAM -eq "vscode") { .
🌐
GitHub
github.com › microsoft › vscode › issues › 34337
Resolve standard VS Code variables in "terminal.integrated.env.*" · Issue #34337 · microsoft/vscode
September 14, 2017 - VSCode Version: 1.15.1 · OS Version: macOS Sierra 10.12.6 · Steps to Reproduce: Update workspace settings to something like · { "terminal.integrated.env.osx": { "PATH": "/home" } } Now open Terminal and look at PATH · echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/home ·
Author   rongduan-zhu
🌐
GitHub
github.com › microsoft › vscode-python › issues › 12085
Setting the `PYTHONPATH` with `terminal.integrated.env.*` does not affect test discovery or debugging · Issue #12085 · microsoft/vscode-python
June 1, 2020 - microsoft / vscode-python Public forked from DonJayamanne/pythonVSCode · Notifications · You must be signed in to change notification settings · Fork 1.3k · Star 4.6k · New issueCopy link · New issueCopy link · Closed · Closed · Setting the PYTHONPATH with terminal.integrated.env.* does not affect test discovery or debugging#12085 ·
Author   lsorber