Upgrade nano on Mac OS X

I have followed the suggestion in this answer How do you update the default version of Nano on MacOS without using the homebrew package manager?

I have macOS High Sierra. After the installation I have tried:

$ nano -V

And the output is:

GNU nano version 2.0.6 (compiled 19:06:01, Oct  6 2017)
 Email: [email protected]    Web: http://www.nano-editor.org/
 Compiled options: --disable-nls --enable-color --enable-extra --enable-multibuffer --enable-nanorc --enable-utf8

So I have tried to see where nano is located:

$ which nano

and the output is

/usr/local/bin/nano

Checking the path:

$ echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin

I don't understand, if the first path is where nano is installed, why the new version is not available.


Solution 1:

When running a binary from your shell, the shell stores its path within PATH in a cache and uses that value for future calls to avoid having to research the path each time. If you then install a new version of this binary in a different location the shell won't notice this and keep running the previous version.

If you are running bash

  • hash -t nano will show the currently used version of nano (if any)
  • hash nano will update the cache for nano

If you are running zsh

  • hash -m nano will show the currently used version of nano (if any)
  • hash -f nano will update the cache for nano