Visual studio code integrated terminal path different than normal terminal

I am on MacOS Mojave and I can't figure out why visual studio code's integrated terminal has a different path variable than the normal terminal.

I have checked that VSCode opens /bin/bash (echo $SHELL yields /bin/bash).

However when executing echo $PATH in the integrated terminal it yields /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/anaconda3/bin:/anaconda3/condabin while on the normal terminal it gives /anaconda3/bin:/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

They both source ~/.bash_profile which contains the following :

# added by Anaconda3 2018.12 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup

Even after sourcing ~/.bash_profile in the integrated terminal, /anaconda3/bin is at the end while ~/.bash_profile prepends it which is confusing.

I think the default path must be added after bash_profile is sourced in the integrated terminal? Not sure how it works

I am hesitating to post this as an issue in the vscode repo but I just wanted to make sure it isn't my understanding that is off.


In Visual Studio Code open Settings (JSON) from the command palete (⇧⌘P), and at the end of the file add the following

"terminal.integrated.env.osx": {
        "PATH": ""
}

Restart VSCode and you are all set.

Taken from https://github.com/Microsoft/vscode-python/issues/4434


You can uncheck Terminal › Integrated: Inherit Env option, which can be searched by terminal.integrated.inheritEnv, in Visual Studio Code Settings like the following image:

enter image description here

Referece: https://github.com/microsoft/vscode/issues/70248#issuecomment-502186149 (Now the option terminal.integrated.inheritEnv is included in the stable build.)