man is using system installtion of less, ignoring PATH

44 Views Asked by At

On my machine, I have the latest version of less installed through homebrew. Around the time me updating to macOS 14, I noticed my man stopped loading less in the latest version. If I run man man and hit V to show the less version, I get less 581.2, which is the system installation of less. But if I export MANPAGER to less, and then re-run the previous steps, I get less 643. If I unexport MANPAGER and open up another man page and run in less ! echo $PATH I see the expected output and that the location of brew installed less ahead of /usr/bin/less. So I can conclude that my PATH is properly passed to man but it's choosing to use /usr/bin/less anyway.

I know I can fix this by just exporting MANPAGER to less, but I never needed this before. This seems really fishy and I'm worried something more pernicious is going on.

Has anyone else run into this problem? What's causing my man to use the system installation of less?

2

There are 2 best solutions below

2
CAAHS On

No idea what your man man prints, but mine does not tell less but pager, so given less is in PATH at the expected location, but pager not (and if I get your question right), then it could make sense that PATH appears non-working from the user-facing side, but it is actually the expectation of the command name from the inside that is not matched.

So while less is used as pager it is pager no less.

Therefore only changing the PATH for less does not suffice for man(1) which is looking for pager, which PATH was not changed for.

echo "$PATH"
command -v pager
command -v less
man pager

Furthermore with your question, and if we're still on the same page, you may want to provide feedback to the homebrew formula authors about your learning and discuss a useful default setting — given man pager actually shows less(1) on your box.

Until then, you could temporarily create a directory entry named pager as a symbolic link of less in the same directory that is in PATH of your homebrew'ed less override and see if it works. This could also work as your proof of concept for any further discussions with the formulas team since at the end of the day this is a programming question, right? Therefore such or other changes need to be filed upstream.

3
punund On

man defines its pager during the ./configure stage before compilation:

MAN_CHECK_PROGS(pager, PAGER, use PAGER as default pager, pager less more)

printf "%s\n" "#define PROG_PAGER \"$pager\"" >>confdefs.h

This means that you are left off with using environment variables, which is perfectly fine, this was designed this way.