MacOS – Specifying $MANPATH after installing coreutils doesn’t affect the man page displayed

bashcommand linehomebrewmacosterminal

I installed the GNU core utilities via brew install coreutils. I also added PATH=$(brew --prefix coreutils)/libexec/gnubin:$PATH
to the beginning of ~/.bash_profile (and it's auto-sourced in ~/.bashrc) as to enable accessing these utilities with their default names, ant not prepended with g.

I also want access to the man pages of these utilities, so I added MANPATH="/usr/local/opt/coreutils/libexec/gnuman:${MANPATH-/usr/share/man}" to ~/.bash_profile as the second line. Unfortunately, when I type man ls for example, I still get the BSD man page, instead of the Gnu one. How do I fix this?

Best Answer

OK, so after researching about $MANPATH with regards to Linux\UNIX, I came across the idea of adding export MANPATH right after defining it in ~/.bash_profile. This solves the problem as required, i.e. giving me access to man pages for coreutils, and only then to their BSD versions, if no GNU version exists.