Example
(from macOS 11.7; also shows up on macOS 12.6.1; these are the only systems I have available to test)
$ pushd "$(mktemp -d /tmp/makewhatis-XXXXXXX)"
$ mkdir man
$ ln -s man sman
$ mkdir man/man1
$ cp /usr/share/man/man1/true.1 man/man1/
$ /usr/libexec/makewhatis -v -o /dev/null man
man directory man
man/man1
reading man/man1/true.1
$ /usr/libexec/makewhatis -v -o /dev/null sman
man directory foo
makewhatis: foo: Not a directory
Context
I noticed this when man -k searches output some failures on stderr about directories not being found. In particular, makewhatis is very unhappy with /Library/TeX/texbin/man, which is a symbolic link installed by the TeX Live for Mac distribution (?) for the manual pages. I've only started seeing this recently, since man works through the symbolic links fine. That is, man -w latex prints /Library/TeX/texbin/man/man1/latex.1, but man -k latex 2>&1 | cat prints (on my system):
pod2latex(1) - convert pod documentation to latex format
makewhatis: /Library/TeX/texbin/man: Not a directory
coq-tex(1) - Process Coq phrases embedded in LaTeX files
Pod::LaTeX(3pm) - Convert Pod data to formatted Latex
pod2latex(1) - convert pod documentation to latex format
I'm not sure if this is Apple-specific (if so, let's move to AskDiffernt?).
I would like to know why this happens, but more importantly how I can fix it without mucking about with installer-created symlinks.