3

Installing Perl modules from the Linux command line using the cpan command works fine, such as:

$ cpan [Module]

and after finishing I can see the module’s documentation via:

$ perldoc [Module]

But doing this via cfengine, which would just automate script the cpan command (in a shellcommands: list), the module gets installed, but perldoc will not work for it:

$ perldoc Text::Histogram
No documentation found for "Text::Histogram".*

However, invoking:

$ man Text::Histogram

will work just fine.

Setting a general environment variable for this (such as suggested by the perldoc man page) doesn't seem feasible as I observe the .pm files being placed in very diverse places.

Any hints about this?

tchrist
  • 78,834
  • 30
  • 123
  • 180
David Ramirez
  • 216
  • 2
  • 8
  • 1
    Are you using a different user (than the cfengine,) when you try running a regular cpan command? – summea Mar 02 '12 at 23:06
  • 1
    Do you have more than one `perl` on your system, but maybe only one `perldoc`? Try `perl $(which perldoc) The::Module`. – mob Mar 02 '12 at 23:18
  • While I would like to know the answer to this one, if it works with `man`, what do you need `perldoc` for? Just curious. Hmm... maybe if you had the [pmtools suite](http://search.cpan.org/dist/pmtools-1.10/) installed, I might ask about conflicting manpaths vs `@INC` paths. – tchrist Mar 03 '12 at 16:50

1 Answers1

3

perldoc searches the Perl module include path (@INC). If perldoc can't find it, perl can't find it. Try perl -wle 'use The::Module' to see if perl can load it. If it can find it, then something weird is going on.

What likely happened, if you installed a module via a third party program (even if it's just using the cpan client), is it got installed to a different location and/or a with a different perl than the one you're using on the command line. There's a number of reasons for this, the three most likely are...

  • It has a different PATH than you and found a different copy of cpan for a different perl.
  • It's configured the cpan client differently to install to a different PATH.
  • cpan is configured to install under the home directory, and it's running as a different user.

There is also the odd chance that the module has no documentation.

You can see what perldoc is doing to find the module with perldoc -D The::Module (this may be -v in older versions).

Schwern
  • 153,029
  • 25
  • 195
  • 336