2

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.

0

2 Answers 2

4

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
0

After making a change to the shell like editing PATH, reload it as follows:

Bash: exec bash

Zsh: exec zsh

(For me hash nano didn't do anything and -t results in bad option: -t.)

2
  • -t only works in bash, the options are different in zsh.
    – nohillside
    Commented May 10, 2021 at 6:14
  • Editing PATH variable would cause the hash table to be thrown out. An old trick is to reassign PATH- PATH=$PATH to clear the hash table.
    – fd0
    Commented May 10, 2021 at 12:32

You must log in to answer this question.

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