Fix rbenv or ruby command not found after changing from bash to zsh
After changing my existing shell console to zsh, I cannot run rbenv or ruby commands. But I already installed both of them.
This happens because I have not yet exported rbenv path to zshrc.
And this solution works for me:
Open your .zshrc file (using nano or vim)
And paste this to the bottom of the file
export PATH=$HOME/.rbenv/bin:$PATH
eval “$(rbenv init -)”
Or if you want a more simple solution, type this on zsh console
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
Both of them do the same thing (write the export and eval task to the zshrc). And those codes will be executed when you are opening a new zsh console.
And then run this to save and make changes to your zshrc configuration
source ~/.zshrc
or this if zsh is already set up as your default shell console.
exec $SHELL
And voila, now you can use rbenv or ruby commands everytime you open a new terminal.