Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 559490 - app-text/manpager: arguments in $PAGER are not handled
Summary: app-text/manpager: arguments in $PAGER are not handled
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal with 1 vote (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-03 09:36 UTC by abandoned account disabled email
Modified: 2023-11-15 01:52 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge -v --info (emerge_v__info.txt,16.85 KB, text/plain)
2015-09-03 09:51 UTC, abandoned account disabled email
Details

Note You need to log in before you can comment on or make changes to this bug.
Description abandoned account disabled email 2015-09-03 09:36:41 UTC
# man man
could not launch PAGER: No such file or directory
man: command exited with status 1: (cd /root && LESS=-ix8RmPm Manual page man(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$PM Manual page man(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$-+X -R -+S -+F -+E -I MAN_PN=man(1) manpager)

# manpager
could not launch PAGER: No such file or directory

dmesg doesn't say anything odd about it:
[13504.086384] grsec: From 10.0.2.2: exec of /usr/bin/manpager (manpager ) by /usr/bin/manpager[bash:2685] uid/euid:0/0 gid/egid:0/0, parent /bin/bash[bash:1571] uid/euid:0/0 gid/egid:0/0

# equery b `which $MANPAGER`
 * Searching for /usr/bin/manpager ... 
app-text/manpager-1 (/usr/bin/manpager)

# equery b `which man`
 * Searching for /usr/bin/man ... 
sys-apps/man-db-2.7.2-r1 (/usr/bin/man)

# equery b '/etc/env.d/00manpager'
 * Searching for /etc/env.d/00manpager ... 
app-text/manpager-1 (/etc/env.d/00manpager)

This file contains the line:
MANPAGER=manpager

I don't know what to tell you but this didn't exist before a few days ago. (Or I'm missing something)


# equery m app-text/manpager
 * app-text/manpager [gentoo]
Herd:        base-system (base-system@gentoo.org)
Maintainer:  None specified
Upstream:    None specified
Homepage:    http://www.gentoo.org/
Location:    /usr/portage/app-text/manpager
Keywords:    1:0: ~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64
                  ~s390 ~sh ~sparc ~x86
License:     GPL-2


Workaround:
# MANPAGER=less man man
(shows the man page perfectly, with colors even!)
# MANPAGER= man man
(also works, but just dumps the whole man page without stopping)



Reproducible: Always
Comment 1 abandoned account disabled email 2015-09-03 09:38:19 UTC
Looks like this is the culprit:

# echo $PAGER
less -+X -R -+S -+F -+E -I

# PAGER= manpager
could not launch PAGER: No such file or directory

# PAGER=less manpager
Missing filename ("less --help" for help)

# PAGER=less man man
Now this works, the colors are different but still, good!

# PAGER="less -I" man man
could not launch PAGER: No such file or directory
man: command exited with status 1: (cd <fd 3> && LESS=-ix8RmPm Manual page man(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$PM Manual page man(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$-+X -R -+S -+F -+E -I MAN_PN=man(1) manpager)

In other words, manpager expects PAGER to be only the filename of the pager, without any args to it!

Should this be considered a bug in manpager, or was it a feature  that it worked thus far as it did  until manpager came to the scene?
Comment 2 abandoned account disabled email 2015-09-03 09:51:18 UTC
Created attachment 410910 [details]
emerge -v --info

Sorry, I was so into it that I forgot to give my emerge --info

# emerge --info
Portage 2.2.20.1 (python 3.4.3-final-0, hardened/linux/amd64/no-multilib, gcc-5.2.0, glibc-2.21-r1, 4.1.6-hardened-r1-g45b4b78 x86_64)
=================================================================
System uname: Linux-4.1.6-hardened-r1-g45b4b78-x86_64-AMD_A6-3400M_APU_with_Radeon-tm-_HD_Graphics-with-gentoo-2.2
KiB Mem:    10809864 total,   1257240 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Thu, 03 Sep 2015 00:45:01 +0000
sh bash 4.3_p42
ld GNU ld (Gentoo 2.25.1 p1.1) 2.25.1
ccache version 3.2.3 [enabled]
app-shells/bash:          4.3_p42::gentoo
dev-lang/perl:            5.22.0::gentoo
dev-lang/python:          2.7.10::gentoo, 3.4.3::gentoo
dev-util/ccache:          3.2.3::gentoo
dev-util/cmake:           3.3.1-r1::gentoo
dev-util/pkgconfig:       0.28-r3::gentoo
sys-apps/baselayout:      2.2::gentoo
sys-apps/openrc:          0.17::gentoo
sys-apps/sandbox:         2.6-r1::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69-r1::gentoo
sys-devel/automake:       1.13.4::gentoo, 1.14.1::gentoo, 1.15::gentoo
sys-devel/binutils:       2.25.1-r1::gentoo
sys-devel/gcc:            4.8.5::gentoo, 5.2.0::gentoo
sys-devel/gcc-config:     1.8::gentoo
sys-devel/libtool:        2.4.6-r1::gentoo
sys-devel/make:           4.1-r1::gentoo
sys-kernel/linux-headers: 4.2::gentoo (virtual/os-headers)
sys-libs/glibc:           2.21-r1::gentoo
Repositories:

gentoo
    location: /usr/portage
    priority: -1000

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=native -ggdb -fvar-tracking-assignments -fno-omit-frame-pointer -ftrack-macro-expansion=2 -fstack-protector-all -fPIC"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -march=native -ggdb -fvar-tracking-assignments -fno-omit-frame-pointer -ftrack-macro-expansion=2 -fstack-protector-all -fPIC"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs ccache cgroup collision-protect config-protect-if-modified distlocks downgrade-backup ebuild-locks fakeroot fixlafiles force-mirror installsources ipc-sandbox merge-sync multilib-strict network-sandbox news nostrip parallel-fetch parallel-install prelink-checksums preserve-libs sandbox sfperms split-elog split-log strict unknown-features-warn unmerge-backup unmerge-logs userfetch userpriv usersandbox webrsync-gpg"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://ftp.romnet.org/gentoo/ http://tux.rainside.sk/gentoo/ http://de-mirror.org/gentoo/ http://gd.tuwien.ac.at/opsys/linux/gentoo/ http://www.las.ic.unicamp.br/pub/gentoo/"
INSTALL_MASK="/lib/systemd /lib32/systemd /lib64/systemd /usr/lib/systemd /usr/lib32/systemd /usr/lib64/systemd /etc/systemd"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j4"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
USE="3dnow 3dnowext X acl amd64 berkdb bindist btrfs bzip2 cli consolekit cracklib crypt cryptsetup cscope cxx dbus device-mapper dri egl extensions gdbm git gpg gpm gtk3 hardened iconv jpeg justify lock mmx mmxext modules mosh-hardening ncurses nptl openmp pam pax_kernel pcre pie policykit pulseaudio qt4 readline seccomp session sse sse2 sse3 ssl ssp startup-notification strong-security system-icu system-jpeg system-libvpx system-sqlite urandom xattr xcomposite xtpax zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="3dnow 3dnowext mmx mmxext sse sse2 sse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="pc" INPUT_DEVICES="keyboard virtualbox evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_4" RUBY_TARGETS="ruby19 ruby20" USERLAND="GNU" VIDEO_CARDS="virtualbox" XFCE_PLUGINS="brightness clock trash battery power" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
USE_PYTHON="2.7"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

-----
but this is AFTER I removed the MANPAGER=manpager setting from /etc/env.d/00manpager
---
Comment 3 SpanKY gentoo-dev 2015-09-03 16:07:44 UTC
if you want to specify options to less, you should be putting them in $LESS, not directly into $PAGER
Comment 4 abandoned account disabled email 2015-09-03 16:36:59 UTC
tl;dr: Makes sense. Thanks SpanKY!


--- details:

Looks like I already had this:
# echo $LESS
-+X -R -+S -+F -+E -I

so this works as expected:
# PAGER=less man man
but the colors(blue+cyan) are different than the green+yellow that I get with:
# MANPAGER=less man man
or the equivalent command: (unset MANPAGER; man man)  [run with parens included]

So with MANPAGER unset, I get the normal less colors(green+yellow). I'll try to keep it this way but will also set PAGER=less (without params! thx)

What I had set in ~/.bashrc :
export LESS="-+X -R -+S -+F -+E -I"
export PAGER="less $LESS"
export GIT_PAGER="$PAGER"

I'm unsure why I had set params to PAGER, I think the  man 1 git-config  here influenced me:

core.pager
           Text viewer for use by Git commands (e.g., less). The value is
           meant to be interpreted by the shell. The order of preference is
           the $GIT_PAGER environment variable, then core.pager configuration,
           then $PAGER, and then the default chosen at compile time (usually
           less).

           When the LESS environment variable is unset, Git sets it to FRX (if
           LESS environment variable is set, Git does not change it at all).
           If you want to selectively override Git’s default setting for LESS,
           you can set core.pager to e.g.  less -S. This will be passed to the
           shell by Git, which will translate the final command to LESS=FRX
           less -S. The environment does not set the S option but the command
           line does, instructing less to truncate long lines. Similarly,
           setting core.pager to less -+F will deactivate the F option
           specified by the environment from the command-line, deactivating
           the "quit if one screen" behavior of less. One can specifically
           activate some flags for particular commands: for example, setting
           pager.blame to less -S enables line truncation only for git blame.

           Likewise, when the LV environment variable is unset, Git sets it to
           -c. You can override this setting by exporting LV with another
           value or setting core.pager to lv +c.
Comment 5 Sean Santos 2016-02-13 10:39:36 UTC
"if you want to specify options to less, you should be putting them in $LESS, not directly into $PAGER"

I don't particularly like this suggestion because you might want to put options in $PAGER that you don't want in $LESS. I think that manpager shouldn't reject PAGER settings that work in man itself. (man seems to deal with this using pipecmd_new_argstr from libpipeline.)

Regardless, the error message here is also not very helpful in this case:

"could not launch PAGER: No such file or directory"

I didn't even know that manpager existed (presumably I pulled it in without noticing it during a world update recently), so I assumed that this message was coming from man itself, and I was really confused as to why the same value of PAGER was not causing any problems on other systems. It wasn't until I started looking through a list of all my environment variables that I noticed that MANPAGER was set, and that this was something that had actually changed (and not something that I'd done and forgot about years ago).

It would have saved some time if the error message had identified itself as being from manpager, rather than being part of the error message that follows it.
Comment 6 Chad Joan 2020-05-07 08:58:43 UTC
I'm not sure why I didn't experience this until my latest update. Or maybe I didn't care that my user account was unable to view man pages because my ~/.bash_profile set PAGER to "less -r". Nonetheless, it seems I'm late to the party.

My workaround is to wrap my pager in a script. That way I don't need to pollute my $LESS variable. I even got it to work if the PAGER is assigned to something besides 'less'.

I created these scripts:

----- /etc/pager-with-args.sh -----------------------------------------
# This script can be referenced in the PAGER variable to allow args to be
# passed to the pager program.
# The args can't be placed directly into the PAGER variable because it will
# cause this error:
#   could not launch PAGER: No such file or directory
#   man: command exited with status 1: ...
# It is discussed in this Gentoo bug regarding the manpager package:
# https://bugs.gentoo.org/559490
exec $PAGER_PATH $PAGER_ARGS $*

----- /etc/profile.d/zz-pager-wrap.sh ---------------------------------
# Wraps the script/executable referenced in the PAGER variable with a script
# (/etc/pager-with-args.sh) that passes the PAGER_ARGS variable into that
# script or executable.
# The contents of the PAGER variable will move to the PAGER_PATH variable,
# which will also be used by the /etc/pager-with-args.sh script.

if [ "$PAGER" != "/etc/pager-with-args.sh" ]; then
        export PAGER_PATH=$PAGER
        export PAGER="/etc/pager-with-args.sh"
fi

----- /etc/profile.d/pager-args-control-chars.sh ----------------------
# ... blah blah ... Here is where I tell my future self why I pass the below
# argument(s) to the PAGER. ...
#
# This script assumes that PAGER is set to /etc/pager-with-args.sh, which is
# a wrapper that calls $PAGER_PATH with $PAGER_ARGS.
#

case " $PAGER_ARGS " in
        (*' '-r' '*) ;;
        (*)
                export PAGER_ARGS="$PAGER_ARGS -r"
        ;;
esac

-----------------------------------------------------------------------

I ran "chmod a+x /etc/pager-with-args.sh" to prevent permissions errors.

The last one is where the args get customized, and it's named after my specific use-case. You could make this file generic and stick all arguments into one file regardless of purpose (harder to understand but easier to read), or make a different files for each set of arguments with related purposes (easier to understand but harder to read). I'm doing the latter and it might not matter: it's somewhat likely that I'll only ever put that one argument in.

I put pager-with-args.sh into /etc but it seems kludgy to me. I did it this way in my case because I want 'man' to still work if my /usr filesystem doesn't mount, and the other directories in / seemed either inappropriate or within portage's jurisdiction.

The zz- in zz-pager-wrap.sh is just to make it execute as late as possible when /etc/profile rummages through the /etc/profile.d directory. That way, if another profile.d script changes the PAGER variable, it won't override the pager wrapping and the wrapping will not be applied to an incorrect PAGER.

Hope that helps.