gugod / App-perlbrew

Manage perl installations in your $HOME
https://perlbrew.pl
Other
719 stars 216 forks source link

perlbrew 0.64 breaks the 'man' command in OpenBSD #357

Open arrestee opened 11 years ago

arrestee commented 11 years ago

From an OpenBSD point of view, __perlbrew_set_path (in etc/bashrc) makes 2 false assumptions about how things work: 1) 'manpath' exists.
2) exporting an empty MANPATH environment var is harmless

The OpenBSD (and, I believe, NetBSD) man command is a complicated beast that parses /etc/man.conf to come up with a list of well over a hundred directories to search for man pages (which, in the absence of 'manpath', I can find no way of printing). That doesn't even consider the extra functionality that lets you list certain directories as belonging only to certain named or numbered sections of the manual (so if you say 'man 3 foo' it won't waste time looking in directories that only have pages for section 1 or for the X11 section).

The system works just fine until you innocently define MANPATH. Then, all those scores of manpage directories get dropped and are replaced by the directories listed in MANPATH (possibly appended-to by specified SUB-directories that may be listed in /etc/man.conf--I told you this was complicated). Of course, the specified directories for specified manual sections are lost--there's no way to replicate that functionality with MANPATH.

Anyway, to get to the point, perlbrew exports an empty MANPATH, and that kills the 'man' command. All the rest is just my way of saying that, since there seems to be no way to append directories to the search list except to edit /etc/man.conf, it's probably best to just not alter OpenBSD's man command at all.

But that's not my call. I fixed this for myself by adding 'unset MANPATH' to the end of .zshenv, but if somebody wants to try something fancier, I'll be happy to help test it.

vovkasm commented 11 years ago

Some thoughts... Right man support is hard. Why it exists at all in the perlbrew, because Perl has a great way to view the documentation - perldoc? I personally prefer not to build man pages at all and not waste build time to this...

May be we can add some option (ENV, config file?) to disable man support? The best is to disable it by default ;-)

gugod commented 11 years ago

@arrestee Thank you very much for the report. We will need your helpto make this works for OpenBSD :smile:

We will need to make the bashrc generation dynamic and platform-dependent. Each platform should probably have an implementation of their own __perlbrew_set_path etc.

Ex3Dophos commented 1 year ago

Hello,

I don't think this issue is limited to just OpenBSD or perlbrew 0.64 (as indicated in the title). I'm using the latest perlbrew (0.98) and ran into the same issue on AIX.

My MANPATH was set before sourcing perlbrew's bashrc, which resulted in my MANPATH not being preserved and only the perlbrew's manpage location existing. I believe the reason this is happening, is because the manpath command does not exist on AIX (i.e. manpath not existing would return an empty result).

Which lines up with the issue of false assumption number 1.

  1. 'manpath' exists.
  2. exporting an empty MANPATH environment var is harmless

As for false assumption number 2, I don't think that has any affect on AIX... but I understand the concern there from an OpenBSD perspective.

In terms of the code, I don't fully understand the line trying to set the MANPATH. Is there a reason why it requires using the manpath command instead of using the MANPATH environment variable... like perlbrew does on the following line for PATH? I'm basically wondering if this would work:

--- /home/myuser/perl5/perlbrew/etc/bashrc     2023-08-16 10:20:02.137156671 +0000
+++ /home/myuser/perl5/perlbrew/etc/bashrc.new 2023-08-16 12:26:56.397137627 +0000
@@ -26,7 +26,7 @@
 }

 __perlbrew_set_path () {
-    export MANPATH=${PERLBREW_MANPATH:-}${PERLBREW_MANPATH:+:}$(__perlbrew_purify "$(manpath 2>/dev/null)")
+    export MANPATH=${PERLBREW_MANPATH:-}${PERLBREW_MANPATH:+:}$(__perlbrew_purify "$MANPATH")
     export PATH=${PERLBREW_PATH:-$PERLBREW_ROOT/bin}:$(__perlbrew_purify "$PATH")
     hash -r
 }

Example snippet of problem (on AIX):

bash-5.1$ perlbrew version
/home/myuser/perl5/perlbrew/bin/perlbrew  - App::perlbrew/0.98
bash-5.1$ echo $MANPATH

bash-5.1$ export MANPATH=/opt/freeware/man:/usr/lpp/X11/man:/usr/man
bash-5.1$ echo $MANPATH
/opt/freeware/man:/usr/lpp/X11/man:/usr/man
bash-5.1$ source ~/perl5/perlbrew/etc/bashrc
bash-5.1$ echo $MANPATH
/home/myuser/perl5/perlbrew/perls/perl-5.38.0/man:

Possible location of perlbrew code causing the issue: https://github.com/gugod/App-perlbrew/blob/17e77ec7ffc075d6d860f6e3f37538c0e8a70aff/perlbrew#L3365-L3369

gugod commented 1 year ago

Thanks all for the investigation work.

I believe this PR is also relevant: https://github.com/gugod/App-perlbrew/pull/215 -- in this the first PR that introduced the use of manpath command, and was part of perlbrew-0.46.

The PR describe an identical problem that was triggered by MANPATH being changed to only perlbrew-related paths if it was initially unset.