Home > Mobile >  Why shell always execute vim in /usr/bin rather than vim in /opt/homebrew/bin?
Why shell always execute vim in /usr/bin rather than vim in /opt/homebrew/bin?

Time:07-11

I don't want to use the vim bundled on the macOS, so I download new vim using homebrew. My environment variable PATH is set as follows: /opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin. The vim downloaded using brew in in /opt/homebrew/bin, and vim bundled with macOS is in /usr/bin. However, when I input vim on the shell, it always execute /usr/bin/vim(i.e. the vim bundled with macOS).

Does anyone know how to solve this or what is the reason for this circumstance? Very appreciate any help.

the situation when I execute vim and tmux in shell

CodePudding user response:

Oh! I know why is that. After installing new vim using brew, we need to reboot the terminal. I know this because I I accidentally shut down the terminal, then I open the terminal and find the vim in /opt/homebrew/bin can be executed when I input vim in the shell.

For beginners, this is a difficult problem to find the reason. I solved this problem myself, hoping to help people who encounter the same problem

  • Related