Skip to content

Commit 5b68d50

Browse files
committed
doc: add "man-path" cookbook recipe
Signed-off-by: Xavier Delaruelle <[email protected]>
1 parent fbaaaaa commit 5b68d50

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed

NEWS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ Modules 5.6.0 (not yet released)
145145
cache file. Freshly generated cache files are compatible with Modules 5.3
146146
and above.
147147
* Doc: improve :ref:`enable-modules-in-shells` guidelines.
148+
* Doc: add :ref:`man-path` cookbook recipe.
148149

149150
.. _Security policy: https://github.com/envmodules/modules/blob/main/SECURITY.md
150151
.. _Modules chat room: https://matrix.to/#/#modules:matrix.org

doc/source/FAQ.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,16 @@ Modules usually uses the the highest lexicographically sorted :ref:`modulefile(5
151151
#%Module
152152
set ModulesVersion native
153153
154+
I cannot access regular man pages now I have loaded some module
155+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
156+
157+
If your system does not have the :envvar:`MANPATH` environment variable set by
158+
default, and you load a module that defines it, you must append a colon
159+
(``:``) to the end of the :envvar:`MANPATH` value. This ensures continued
160+
access to the system's default man pages.
161+
162+
See :ref:`man-path` cookbook recipe for details.
163+
154164
I don't want a *default* modulefile for the directory?
155165
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
156166

doc/source/cookbook/man-path.rst

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
.. _man-path:
2+
3+
Handle man pages search path
4+
============================
5+
6+
Man pages (manual pages), read with :command:`man` command, are stored in a
7+
structured directory hierarchy under predefined locations. They are typically
8+
stored within ``/usr/share/man`` and software-specific *man* directories.
9+
10+
:command:`man` searches for man pages the following way:
11+
12+
* if :envvar:`MANPATH` environment variable is set, man pages are only
13+
searched in the directories specified in it
14+
* if :envvar:`MANPATH` is not set, :command:`man` determines the hierarchy
15+
search path using information gained from the ``man-db`` configuration
16+
17+
See `SEARCH PATH section`_ of ``manpath(5)`` man page to learn how ``man-db``
18+
computes the default search path.
19+
20+
.. _SEARCH PATH section: https://man7.org/linux/man-pages/man5/manpath.5.html#SEARCH_PATH
21+
22+
The :command:`manpath` command can be used to observe the currently active
23+
search path:
24+
25+
.. parsed-literal::
26+
27+
:ps:`$` manpath
28+
/usr/local/share/man:/usr/share/man
29+
:ps:`$` export MANPATH=/usr/share/man
30+
:ps:`$` manpath
31+
manpath: warning: $MANPATH set, ignoring /etc/man_db.conf
32+
/usr/share/man
33+
34+
Systems usually do not define :envvar:`MANPATH` by default and rely on
35+
``man-db`` configuration. On such systems, if a modulefile adds a specific
36+
man page directory to :envvar:`MANPATH`, :command:`man` will not be able to
37+
find system regular man pages anymore.
38+
39+
.. parsed-literal::
40+
41+
:ps:`$` man --where ls
42+
/usr/share/man/man1/ls.1.gz
43+
:ps:`$` module show foo/1.0
44+
-------------------------------------------------------------------
45+
:sgrhi:`/path/to/modulefiles/foo/1.0`:
46+
47+
:sgrcm:`append-path` PATH /path/to/foo-1.0/bin
48+
:sgrcm:`append-path` MANPATH /path/to/foo-1.0/man
49+
-------------------------------------------------------------------
50+
:ps:`$` module load foo/1.0
51+
:ps:`$` man --where ls
52+
No manual entry for ls
53+
54+
To retain access to the system man pages when modulefiles modify the
55+
:envvar:`MANPATH`, the default search paths must be added into
56+
:envvar:`MANPATH`. This can be done by appending a colon (``:``) to the end of
57+
the :envvar:`MANPATH` value, which instructs the system to include its default
58+
man page directories.
59+
60+
.. parsed-literal::
61+
62+
:ps:`$` manpath
63+
manpath: warning: $MANPATH set, ignoring /etc/man_db.conf
64+
/path/to/foo-1.0/man
65+
:ps:`$` man --where ls
66+
No manual entry for ls
67+
:ps:`$` module append-path MANPATH :
68+
:ps:`$` man --where ls
69+
/usr/share/man/man1/ls.1.gz
70+
71+
If your modulefiles modify :envvar:`MANPATH`, it is recommended to initialize
72+
this environment variable with a single colon (``:``) during Modules startup.
73+
To do this, add the following line to the ``initrc`` configuration file
74+
(typically located in ``/etc/environment-modules``):
75+
76+
.. code-block:: tcl
77+
78+
append-path MANPATH :
79+
80+
.. vim:set tabstop=2 shiftwidth=2 expandtab autoindent:

0 commit comments

Comments
 (0)