Closed injust closed 2 days ago
cc @moonfruit
I'm not sure how #35874 managed to work. Perhaps macOS changed their MANPATH construction logic after that PR was committed, because the current manpath
man page reads:
The
manpath
utility constructs the manual path from two sources:
- From each component of the user's PATH for the first of:
pathname/man
pathname/MAN
- If pathname ends with
/bin
:pathname/../share/man
andpathname/../man
Since /gnubin != /bin
, the corresponding /man
would never be added, so #35874 is quite useless now.
I've confirmed this by reading the man
and manpath
sources (they're the same shell script).
To fix, one of the following needs to be done:
/gnubin
to /bin
across the board.Yes, #35874 is not working properly now. I also create a PR #135272 to fix this. But this latter PR was not accepted and has been closed. So I had to add some scripts on my own computer to automate what was in this PR. @gromgit @injust
@Homebrew/maintainers, what was the rationale for using libexec/gnu{bin,man}
instead of the conventional libexec/{bin,man}
for, say, Homebrew-wrapped binaries?
@Homebrew/maintainers, what was the rationale for using
libexec/gnu{bin,man}
instead of the conventionallibexec/{bin,man}
for, say, Homebrew-wrapped binaries?
It looks like gnubin
was copied from MacPorts. Ref: https://github.com/Homebrew/legacy-homebrew/commit/c53e35ed6560fe2074c0a5e9ca2ddbec11a7d155
- libexec/gnubin directory contains symlinks to all the coreutils
commands without its program-prefix "g". (Inspired by MacPorts'
coreutils)
gnuman
was probably created based on gnubin
name (https://github.com/Homebrew/legacy-homebrew/commit/372c0d76849aaa18282e1841021588c74f2bf3a3). MacPorts instead used libexec/gnubin/man/
(https://github.com/macports/macports-ports/blob/master/sysutils/coreutils/Portfile#L94).
MacPorts instead used
libexec/gnubin/man/
(https://github.com/macports/macports-ports/blob/master/sysutils/coreutils/Portfile#L94).
Yeah, that would trigger the current macOS man path logic, so that's a third option, that's probably the least disruptive of all:
~3. Move the man
symlink created in #35874, from libexec/man
to libexec/gnubin/MAN
(to avoid confusion with the man
command).~
Turns out the standard Linux man
implementation does the same thing as macOS, only one of the default directories it adds is binpath/../man
, which is covered by #35874, so...
libexec/gnuman
to libexec/gnubin/MAN
(to avoid confusion with the man
command).However, there's another issue: if $MANPATH
is not empty (and brew shellenv
ensures it's not), man
only adds $PATH
-derived man directories under the following circumstances:-
$MANPATH == :*
--> prepend derived directories$MANPATH == *:
--> append derived directories$MANPATH == *::*
--> insert derived directories between the two colonsNow, brew shellenv
adds a trailing colon to MANPATH (case 2), so system man pages will always shadow Homebrew pages of the same name, which I think defeats the whole purpose of deriving man dirs dynamically, particularly since people would logically prepend gnubin
directories to their PATH.
Ironically, having brew shellenv
not set MANPATH at all (or simply prepending a colon if it's already been set) seems to be the Right Thing going forward.
Is there a flaw in my logic?
gnuman
was probably created based ongnubin
name (Homebrew/legacy-homebrew@372c0d7). MacPorts instead usedlibexec/gnubin/man/
(macports/macports-ports@master
/sysutils/coreutils/Portfile#L94).
Yes, this is indeed a viable option. This solution gets around the problem of confusing directory names: bin
vs gnubin
. Just kind of breaks the regular Linux directory layout.
Ironically, having
brew shellenv
not set MANPATH at all (or simply prepending a colon if it's already been set) seems to be the Right Thing going forward.
Couldn't agree more.
Ironically, having
brew shellenv
not set MANPATH at all (or simply prepending a colon if it's already been set) seems to be the Right Thing going forward.
Yes, agreed. Could you open a PR @gromgit? No worries if not.
MacPorts instead used
libexec/gnubin/man/
(macports/macports-ports@master
/sysutils/coreutils/Portfile#L94).Yeah, that would trigger the current macOS man path logic, so that's a third option, that's probably the least disruptive of all
This also seems like a good idea. I'd be in favour of doing both.
@homebrew/core any thoughts on the above?
Yes, agreed. Could you open a PR @gromgit? No worries if not.
I'll take care of that in a few hours.
brew gist-logs <formula>
link ORbrew config
ANDbrew doctor
outputVerification
brew doctor
output saysYour system is ready to brew.
and am still able to reproduce my issue.brew update
and am still able to reproduce my issue.brew doctor
and that did not fix my problem.What were you trying to do (and why)?
I want to install
coreutils
, follow the caveats, and:ls
withls
ls
man page withman ls
What happened (include all command output)?
ls
runs GNUls
man -w ls
prints/usr/share/man/man1/ls.1
andman ls
displays the macOSls
man page instead of the GNUls
man pageWhat did you expect to happen?
man ls
should display the GNUls
man page.In #35874, this caveat was removed:
But
man ls
still displays the macOSls
man page, i.e. the changes in #35874 just don't work on my system. I'm not sure how the default manual path is constructed, but macOS man pages are being preferred overcoreutils
man pages, even if I prepend/usr/local/opt/coreutils/libexec/gnubin
toPATH
.I had to prepend
/usr/local/opt/coreutils/libexec/gnuman
toMANPATH
to getman ls
working.coreutils
is just an example here. This also goes for other Homebrew formulae, e.g.findutils
,gnu-sed
,grep
, anduutils-coreutils
.Step-by-step reproduction instructions (by running
brew
commands)