Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opam breaks man #3391

Closed
RalfJung opened this issue Jun 5, 2018 · 3 comments · Fixed by #3404
Closed

opam breaks man #3391

RalfJung opened this issue Jun 5, 2018 · 3 comments · Fixed by #3404
Assignees

Comments

@RalfJung
Copy link

RalfJung commented Jun 5, 2018

If your issue concerns a package not building, please report to
https://github.com/ocaml/opam-repository/issues or to the package maintainer
unless you are confident it is an issue in the opam tool itself.

When no MANPATH is set, running the opam init script sets the MANPATH in a way that it is broken. This breaks every man page.

$ echo $MANPATH
/home/r/.opam/system/man:/home/r/.opam/system/man
$ man git
No manual entry for git
See 'man 7 undocumented' for help when manual pages are not available.
$ MANPATH= man git
# <man page appears>
# opam config report
# opam-version      2.0.0~rc # but this is really rc2
# self-upgrade      no
# system            arch=x86_64 os=linux os-distribution=debian os-version=testing
# solver            builtin-mccs+glpk
# install-criteria  -removed,-count[version-lag,request],-count[version-lag,changed],-changed
# upgrade-criteria  -removed,-count[version-lag,solution],-new
# jobs              8
# repositories      4 (http), 5 (local), 1 (version-controlled) (default repo at 61536b7f)
# pinned            1 (rsync)
# current-switch    system
@dra27
Copy link
Member

dra27 commented Jun 6, 2018

Possibly related to #2870

@AltGr
Copy link
Member

AltGr commented Jun 8, 2018

Hmm, this is indeed weird, the MANPATH variable should never be given such a value. It is set selectively depending on the system, but always by adding :OPAM_MAN_PATH, including the colon:

% MANPATH= opam env | grep ^MAN
MANPATH=':/home/lg/.opam/4.05.0/man'; export MANPATH;
% unset MANPATH && opam env | grep ^MAN
MANPATH=':/home/lg/.opam/4.05.0/man'; export MANPATH;
% MANPATH=foo opam env | grep ^MAN
MANPATH='foo:/home/lg/.opam/4.05.0/man'; export MANPATH;
% MANPATH=:/home/lg/.opam/4.05.0/man opam env | grep ^MAN
MANPATH=':/home/lg/.opam/4.05.0/man'; export MANPATH;
% MANPATH=/home/lg/.opam/4.05.0/man opam env | grep ^MAN 
MANPATH=':/home/lg/.opam/4.05.0/man'; export MANPATH;

with GNU man, the leading colon means "first use the default value", and is thus correct when MANPATH was previously unset.
On switch init, the environment is generally updated without calling opam, using ~/.opam/opam-init/variables.*sh:

% grep ^MAN ~/.opam/opam-init/variables.sh
MANPATH="$MANPATH":'/home/lg/.opam/4.05.0/man'; export MANPATH;

Could you check the output of the above commands and the contents of variables.sh to help me debug? It seems that at some point, the variable got set to the opam path without the colon, and then the variables.sh file got loaded. But how and why ?

Thanks!

@RalfJung
Copy link
Author

$ grep ^MAN ~/.opam/opam-init/variables.sh
MANPATH="$MANPATH":'/home/r/.opam/system/man'; export MANPATH;

The problem is actually in the environment produced by opam env, as the following shows:

$ MANPATH=:/home/r/.opam/system/man:/home/r/.opam/system/man opam env --shell=bash --readonly
OPAM_SWITCH_PREFIX='/home/r/.opam/system'; export OPAM_SWITCH_PREFIX;
CAML_LD_LIBRARY_PATH='/home/r/.opam/system/lib/stublibs:/usr/local/lib/ocaml/4.05.0/stublibs:/usr/lib/ocaml/stublibs'; export CAML_LD_LIBRARY_PATH;
OCAML_TOPLEVEL_PATH='/home/r/.opam/system/lib/toplevel'; export OCAML_TOPLEVEL_PATH;
MANPATH='/home/r/.opam/system/man:/home/r/.opam/system/man'; export MANPATH;
PATH='/home/r/.opam/system/bin:/home/r/.opam/system/bin:/home/r/bin:/home/r/.cargo/bin:/home/r/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games'; export PATH;

opam env gets called with a sensible MANPATH (starting with a colon) but produces a path without leading colon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants