1

I installed nano 3.0 with brew install nano, but when I run nano --version, it shows version 2.0.6, which is what came with macOS.

Screenshot: enter image description here

echo $PATH also shows that /usr/local/bin is listed before /usr/bin

How do I make running nano use version 3.0 and not 2.0.6?

This doesn't help as nano is already in /usr/local/bin and /usr/local/bin is listed first in $PATH and /etc/paths.

  • 4
    You don't make nano "use" anything. You run the executable you want, from the shell. Bash keeps a hash of where binaries are, if you type 'type nano', and it shows you the system-provided one, restart your shell or use the command 'hash -r' to force the shell to re-hash the paths. Also, 'cat /etc/paths' is meaningless, instead 'echo $PATH'. – Marc Wilson Sep 14 '18 at 3:14
  • 1
    @MarcWilson Thanks. Could you post the hash -r solution as an answer so I can accept it? – abc Sep 14 '18 at 5:02
  • /etc/paths doesn't matter much, it's a mere template to build your PATH env variable, which may be later modified. So you should rather check output of echo $PATH – Michał Szajbe Sep 14 '18 at 5:22
  • Did you try restarting your terminal session? – Michał Szajbe Sep 14 '18 at 5:25
2

You don't make nano "use" anything. You run the executable you want, from the shell. Bash keeps a hash of where binaries are. If you type type nano, and it shows you the system-provided one, restart your shell or use the command hash -r to force the shell to re-hash the paths. Also, cat /etc/paths is meaningless, instead echo $PATH.

0

Use the console command which nano to determine which copy of nano the shell is finding as it walks through your $PATH.

echo $PATH to see what $PATH presently contains.

If you give an explicit file reference to the executable file that you wish to execute, the shell will of course execute that file. Otherwise, it will search $PATH, and the which command gives you the outcome of that search process.

  • Shells keep a history of previous run commands and consult that list before searching $PATH. The comment by Marc Wilson is the correct answer. – fd0 Sep 14 '18 at 15:09
  • Now, I have never, ever heard that! Can you please point me to a reference, say in man bash, that confirms this? (On my system, the man-page says zippety-doo-dah zilch about the command.) – Mike Robinson Sep 14 '18 at 15:42
  • You can start with help hash in your bash shell and from the Bash Reference Manual- Bash uses a hash table to remember the full pathnames of executable files to avoid multiple PATH searches – fd0 Sep 14 '18 at 16:10
  • 1
    Thanks for the answer, but I've already tried this and it didn't work. Marc Wilson's comment worked, so I'm just waiting for him to post it as an answer so I can accept it. – abc Sep 14 '18 at 16:36
0

Please check your aliases. You may have defined your nano alias to point to the old version of nano

$ alias
alias firefox='open -a /Applications/Firefox.app'
alias itune='open -a /Applications/iTunes.app'
alias safari='open -a /Applications/Safari.app'
alias showhidden='ls -al | grep '\''@'\'' | grep -v '\''.DS_Store'\'''
alias showpath='set | grep "^PATH="'
alias textedit='open -e '
alias tofu='open -a /Applications/Tofu.app'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .