path_helper will not set MANPATH

Originally posted in the OS X 10.6 forum, since I didn't think of path_helper as "classical" *nix...but this was suggested as a potentially better forum.

For some reason, path_helper has stopped setting the MANPATH variable for login shells...and I have no clue why.

It still sets the PATH variable - in fact, if run from the command line, i get this output:

$ /usr/libexec/path_helper -s
PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/mysql/bin:/usr/tex bin:/usr/X11/bin"; export PATH;
$
path_helper should be picking up the contents of /etc/manpaths and /etc/manpaths.d and displaying another line setting and exporting the MANPATH.

/etc/manpaths and /etc/manpaths.d/ exist and have appropriate permissions (root:wheel 644 on the files and 755 on the dirs). I'm at a loss as to why its not doing its job properly.

Of couse, a workaround is simple enough, since I can just add the MANPATH manually to the .bash_profile files for my accounts (or even to /etc/profile), but that's not how its supposed to work anymore, so I'd like to get things working properly if possible.

MacBook Pro, Mac OS X (10.6.1)

Posted on Oct 5, 2009 5:52 AM

Reply
17 replies

Oct 5, 2009 3:54 PM in response to BobHarris

Oh it's being called by /etc/profile when a shell launches. At least, it appears to be, since the PATH is being set and includes all the entries in /etc/paths.d, like the paths to mysql and texbin, which aren't otherwise set anywhere.

But the MANPATH stubbornly refuses to set...

You know, I think I'm going to try running it on the command line again, but this time using bash -x.

EDIT - never mind, it's a binary file, not a script.

Oct 5, 2009 4:51 PM in response to g_wolfman

OK, sorry for the double post, but I though this was better served standing independently.

As mentioned before, if nothing is set in the usual places for login (/etc/profile, /etc/bashrc, ~/.bash_profile and ~/.bashrc) then the only output produced by /usr/libexec/path_helper is:

$ /usr/libexec/path_helper -s
PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/mysql/bin:/usr/tex bin:/usr/X11/bin"; export PATH;
$

ie, only the PATH environment variable is being set. However, I now find that if I have set the MANPATH in ~/.bash_profile, then the output becomes:

$ /usr/libexec/path_helper -s
PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/mysql/bin:/usr/tex bin:/usr/X11/bin"; export PATH;
MANPATH="/usr/share/man:/usr/local/share/man:/usr/local/mysql/man:/Library/TeX/D istributions/.DefaultTeX/Contents/Man:/Library/Tor/share/man:/usr/X11/share/man" ;
export MANPATH;
$

So if the MANPATH exists, then at the very least path_helper is exporting the MANPATH (not that it matters, since it's already set)...or, I think that's what's happening.

This is truly annoying.

Oct 6, 2009 7:45 AM in response to g_wolfman

This is happening to me as well. It seems as though it began within the last week. I recently updated to 10.6.1 and added a Time Capsule to my setup, turning on Time Machine in the process. Neither of them seem particularly implicated, but those are my recent changes.

I can work around this by entering:
MANPATH=
export MANPATH
eval `/usr/libexec/path_helper -s`

But I'd prefer to know why this stopped working and fix it.

Oct 6, 2009 11:10 AM in response to g_wolfman

Mark, that doesn't work for me. When I enter "man -w", I see valid paths, but they aren't actually used when I try to read a manual page. Check out this Terminal transcript:

El Smeg:~$ echo $MANPATH

El Smeg:~$ man -w
/usr/local/share/man:/usr/share/man:/usr/local/git/share/man:/usr/X11/man
El Smeg:~$ git help log
No manual entry for git-log
El Smeg:~$ MANPATH=
El Smeg:~$ export MANPATH
El Smeg:~$ eval `/usr/libexec/path_helper -s`
El Smeg:~$ echo $MANPATH
/usr/share/man:/usr/local/share/man:/usr/local/git/man:/usr/X11/share/man
El Smeg:~$ git help log
<the man page for git log now appears>

Oct 7, 2009 6:36 AM in response to Jason Harris

I'd also point out that moving man pages is a burden, especially if it has to be repeated after every upgrade. I don't, for example, want to have to move the man pages for TeX or TOR every time I make a change to the installed tools.

Of course, setting the MANPATH in /etc/profile or ~/.bash_profile works as well, but now there are two sperate methods being used for setting the PATH and the MANPATH.

And finally, as Jason Harris mentioned, there's the simple fact of just wanting the installed core components of the OS to work properly! It's a trust issue, if nothing else; after 10 years I would hope the OS is well-tuned...

Oct 7, 2009 10:03 AM in response to g_wolfman

The indented behavior of the path_helper binary is not to set the MANPATH variable. This allows man to set up it's own search paths according to your $PATH. $MANPATH creates a static search path for man. man's search paths are dynamic. Here's an example of dynamic search paths->

% echo $PATH
/usr/local/bin:/usr/local/sbin:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
% man -w
/usr/local/share/man:/sw/share/man:/usr/share/man:/usr/X11/man
% man sql
No manual entry for sql
% export PATH="$PATH:/usr/local/mysql/bin"
% echo $PATH
/usr/local/bin:/usr/local/sbin:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/usr/local/mysql/bin
% man -w
/usr/local/share/man:/sw/share/man:/usr/share/man:/usr/X11/man:/usr/local/mysql/man

The man page for mysql is available without having to adjust $MANPATH.

+"And finally, as Jason Harris mentioned, there's the simple fact of just wanting the installed core components of the OS to work properly! "+

Well, you should talk to the developers of these products. Setting a non-standard man path isn't up to the OS to figure out. In Jason's case, compiling git fails to create the manpages. You have to download and install the manpages separately. There are a number of options available to you without moving the manpages. Read man man and look at man.conf. There's no reason to double your effort when configuring your shell. Let path_helper set your PATH then extend it in your bash_profile->

export PATH="$PATH:/usr/local/mysql/bin:/usr/texbin:"

If you want a static man search path then set MANPATH in your bash_profile->

export MANPATH="`man -w`:/Library/TeX/Distributions/.DefaultTeX/Contents/Man:/Library/Tor/share/man"

Oct 8, 2009 9:19 AM in response to Mark Jalbert

I beg to disagree about the intended behaviour of path_helper. Its own manpage reads:

The path_helper utility reads the contents of the files in the directories /etc/paths.d and /etc/manpaths.d and appends their contents to the PATH and MANPATH environment variables respectively. (The MANPATH environment variable will not be modified unless it is already set in the environment.)


The bit in the parentheses is the kicker, of course, but path_helper would, I would imagine, set that with the defaults (from the man page):

Prior to reading these directories, default PATH and MANPATH values are obtained from the files /etc/paths and /etc/manpaths respectively.


And man's searches can be dynamic, yes...if not overridden by $MANPATH or command line parameters. But the dynamic searches are based on the contents of man.conf - in particular:

# Every automatically generated MANPATH includes these fields
#
MANPATH /usr/share/man
MANPATH /usr/local/share/man
MANPATH /usr/X11/man


Now, man's dynamic searches are definitely smart enough to find mysql, but not, for example, TOR. Now, TOR is held inside the Library folder /Library/Tor, but installs symlinks to /usr/bin. So if man's dynamic searches would resolve symlinks and extend the searches into those paths, it would probably work, but it doesn't. It's only a so-so-smart heuristic search.

As for the products' developers, if they are putting files in the /etc/manpaths.d directory then they are doing the right thing. It's supposed to be a mechanism for allowing non-standard man pages to be found by the OS - just like it's supposed to be a mechanism for non-standard paths to be picked up.

Now maybe I'm wrong about the whole thing. But if so, then Apple might want to imitate the OpenBSD crew and make sure the man pages are correct. Because right now the man page for path_helper seems pretty clear on what its supposed to do.

Oct 8, 2009 11:51 AM in response to g_wolfman

(The MANPATH environment variable will not be modified unless it is already set in the environment.)


You might try reading that a few more times. The fix is fairly easy. Set your /etc/profile like this->

# System-wide .profile for sh(1)
export MANPATH
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi


If you want path_helper to also set your path then edit /etc/paths or add files to /etc/paths.d/

Nov 16, 2009 1:18 PM in response to Mark Jalbert

I've read this thread through twice and I have to agree with Wolfman et. al. - there's something flakey going on here with path_helper.

First of all, according to the man man page:

ENVIRONMENT
MANPATH
If MANPATH is set, man uses it as the path to search for manual page
files. It overrides the configuration file and the automatic search
path, but is overridden by the -M invocation option. See SEARCH PATH
FOR MANUAL PAGES.


My /etc/profile looks like this (MANPATH is not explicitly set):

/etc: btf$ cat profile
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi


So, in my default configuration I get:

~: btf$ echo $MANPATH

~: btf$

~: btf$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/mysql/bin:/usr/local/bin /sandbox/Debug:/usr/local/bin/sandbox/Release:/usr/X11/bin


This is all as I expect. However, take a look at the following build-up for the Automatic Search Path:

/etc: btf$ cat manpaths
/usr/share/man
/usr/local/share/man
/etc: btf$ cd manpaths.d
/etc/manpaths.d: btf$ ls
./ ../ X11 local mysql
/etc/manpaths.d: btf$ cat x11
/usr/X11/share/man
/etc/manpaths.d: btf$ cat mysql
/usr/local/mysql/man
/etc/manpaths.d: btf$ cat local
/usr/local/man


and YET, when I check the search path, I find that the "local" ( /usr/local/man ) segment is missing:

/etc/manpaths.d: btf$ man -w
/usr/share/man:/usr/local/share/man:/usr/local/mysql/man:/usr/X11/man


This whole issue came about when I added growlinfo, which places its man page in /usr/local/man. I added the "local" file to manpaths.d (in the same way that I had previously added the "mysql" file to manpaths.d). Later on, I thought that perhaps "local" wasn't the best name for this file, so I renamed it to "growl" and tried again. Still no dice:

/etc/manpaths.d: btf$ sudo mv local growl
Password:
/etc/manpaths.d: btf$ ls
./ ../ X11 growl mysql
/etc/manpaths.d: btf$ cat growl
/usr/local/man
/etc/manpaths.d: btf$
(logout and login again)
~: btf$ man -w
/usr/share/man:/usr/local/share/man:/usr/local/mysql/man:/usr/X11/man


So now, just for s**ts and giggles, let's turn off path_helper and see what happens:

/etc: btf$ cat profile
# System-wide .profile for sh(1)
#if [ -x /usr/libexec/path_helper ]; then
# eval `/usr/libexec/path_helper -s`
#fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi


Launch new shell and view paths:

~: btf$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin
~: btf$ echo $MANPATH
~: btf$
~: btf$ man -w
/usr/share/man:/usr/local/share/man:/usr/X11/man


As you can see both $PATH and the Auto Create MANPATH are significantly shorter in the absence of path_helper, so we no that it IS doing something - just not everything ! (Note that the Auto Created MANPATH no longer includes the mysql reference, which is as expected in the absence of path_helper. I'm guessing that X11 is somehow still included due to the heuristic search algorithm)

So, the question is Why does path_helper see and append the mysql reference, but not the local (growl) reference ???

Nov 16, 2009 4:31 PM in response to B_Farrell

Plese read the Mark Jalbert's last post again.

path_helper does not modify (or set) MANPATH if MANPATH is not set when it is called.

If you want to controll MANPATH by /etc/manpaths and /etc/manpaths.d/, then "export MANPATH" before calling path_helper, as Mark suggested.
Or you can modify /etc/man.conf.

If MANPATH is not set, and if /foo/bar/bin is in your PATH, then man command automatically searches for the corresponding man pages in /foo/bar/man. This automatic search does not work for /usr/local/man, however. See /etc/man.conf and 'man man' (seach for keywords MANPATH_MAP and AUTOPATH).

Nov 16, 2009 7:51 PM in response to Jun T.

I really don't want to get into argument here, but your answer makes no more sense to me than the one that you are referring to (Mark Jalbert's last post). I wrote my initial post because I was in agreement with g_wolfman's last post. I still am.

Placing "export MANPATH" in /etc/profile does nothing to alleviate this problem - and doesn't make sense in any case, because as per wolfman's post and the path_helper man page:

Prior to reading these directories, default PATH and MANPATH values are obtained from the files /etc/paths and /etc/manpaths respectively.


--> So MANPATH is already set, unless /etc/manpath is blank or does not exist. My system does have this file and it does contain MANPATH info.

You also mention that AUTOPATH does not work for /usr/local/man , but you do not explain why and I find no reason why this would be so in 'man man', man.conf, or 'man path_helper'.

The easiest work-around is to add 'MANPATH /usr/local/man' to man.conf, which is what I have done, but this seems to defeat the whole idea of AUTOPATH using the manpaths.d directory. This is my whole point - path_helper does not appear to work as documented on its man page...

Message was edited by: B_Farrell

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

path_helper will not set MANPATH

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.