Home > Software engineering >  Anyone know why my .bash_profile is adding "export pyenv" everytime i open terminal?
Anyone know why my .bash_profile is adding "export pyenv" everytime i open terminal?

Time:01-16

I had an issue where vscode was loading terminal in a blank screen and i got an error message in vscode saying "Unable to resolve your shell environment".

So i decided to check my .bash_profile file and was suprised to find it was over 700 lines where it was mainly just the following code repeated:

export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"

I deleted the file and reopened terminal and realised everytime I open terminal, it adds the following lines:

export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"

I installed pyenv straight forward following guides online so i'm not sure what time doing wrong.

If i delete .bash_profile then reopen terminal, it recreates the .bash_profile and adds the following code.

export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

Anyone have any ideas how to fix this?

Note: I also have a .zhrc with the following exports which work as intended:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

export PATH=${PATH}:/usr/local/mysql/bin/

export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"

CodePudding user response:

Check the other profiles that are loaded into the terminal, e.g. .bashrc and .profile (or .zshrc and .zprofile for zshell).

I had a similar issue where my .bashrc contained a script that would add the pyenv lines to another profile every time it was run.

  • Related