0

I'm running macosBig Sur currently. I recently added some commands to my .zshrc file for using pythonenv in my terminal.

The commands run as follows:

export PATH="$HOME/.local/bin"
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init --path)"
  eval "$(pyenv init -)"
fi

However, in the course of changing my zshrc file, something happened, and my terminal was broken. I can no longer even run the ls or any terminal commands. When i run ls, I get the following error:

zsh: command not found: ls

When I echo out my path, i see that it is currently set to

echo $PATH
/Users/myuser/.pyenv/bin:/Users/myuser/.local/bin

I can add the following line

export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

to my .zshrc file to get normal commands like ls working again (the file now looks like this)

export PATH="$HOME/.local/bin"
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init --path)"
  eval "$(pyenv init -)"
fi
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

However, when i do that and reset my terminal, I find that the export commands above the export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin command do not work. It appears the last command is overwriting the other commands, but I'd like for them all to take effect. How would I modify the file to make sure all of the commands are respected by my terminal?

Luke
  • 1,736
  • 2
  • 16
  • 34
  • 1
    The command `export PATH="$HOME/.local/bin"` removes all previous entries from `PATH` (including the directories where commands like `ls` are). You probably want `export PATH="$PATH:$HOME/.local/bin"` instead, which *adds* to the previous entries. – Gordon Davisson May 31 '23 at 07:40

0 Answers0