tmulher has asked for the wisdom of the Perl Monks concerning the following question:

I'm just getting started with scripting so please bear with me. I am able to use perldoc in a windows terminal but when I try 'perldoc perl' in a GIT bash I receive an error:

Can't locate Pod/Perldoc.pm in @INC (@INC contains: /usr/lib/perl5/5.8.8/msys /usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/msys /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl .) at /c/ strawberry/perl/bin/perldoc line 5. BEGIN failed--compilation aborted at /c/strawberry/perl/bin/perldoc line 5.

Here is the code in perldoc

#!perl require 5; BEGIN { $^W = 1 if $ENV{'PERLDOCDEBUG'} } use Pod::Perldoc; exit( Pod::Perldoc->run() );

I much prefer using a GIT bash so I would really like to fix this.

Thank you for your time.

Replies are listed 'Best First'.
Re: perldoc GIT bash
by MidLifeXis (Monsignor) on Mar 28, 2014 at 15:23 UTC

    Does the strawberry version of perldoc have a shebang line of #!/usr/bin/perl (I believe it does)?. What is happening is that the git shell is looking at the shebang line for the perldoc script which is first in your path. According to Unix semantics, it looks at the first line for the interpreter to run, which (according to your path) is the msys version installed with the git shell. So, you are running Strawberry's perldoc with the git shell (msys) perl, libraries, and other things.

    I have not gotten around to checking and/or submitting a bug with strawberry for this yet, but in my opinion, the scripts should either be installed with the full path to the perl binary from the installation, or just #!perl. If the shebang is changed to #!perl, you need to ensure that the Strawberry perl is first in your path.

    After checking my install, it appears that only some of the perl scripts in Strawberry's installation are configured with full paths for the shebang line, which causes its own set of issues. Those are the items that should have a bug attached to them, either in the package, or on Strawberry itself. (IMO, of course)

    Update: Corrected post based on checking my current Strawberry install

    --MidLifeXis

      After checking my install, it appears that only some of the perl scripts in Strawberry's installation are configured with full paths for the shebang line, which causes its own set of issues. Those are the items that should have a bug attached to them, either in the package, or on Strawberry itself. (IMO, of course)

      Hmm, seeing how win32 perl doesn't rely on shebang, has cmd.exe as its shell ... where as msysgit (git-bash) comes with its own perl ... doesn't look like strawberryperl needs any bug reports regarding this

        Unless you are only using the shell from msys, and using the Strawberry perl installation. This is as the OP stated.

        I actually agree that Strawberry is not the proper place for the bug report. I would argue that it is a bug in the original packages that are included in the Strawberry distribution. Even if not on Strawberry with an msys shell, the same thing can happen with multiple perl installations under unix. If the shebang is hardcoded in the distribution and the installation script does not rewrite the shebang line to the full path of the perl installation it is installed into, the script will use the wrong perl when executing itself. Under unix, it appears that the script gets rewritten (at least what I could test). Under Strawberry, it does not look like it does.

        An interesting scenario probably best to be avoided.

        --MidLifeXis

Re: perldoc GIT bash
by kcott (Archbishop) on Mar 28, 2014 at 16:21 UTC

    G'day tmulher,

    Welcome to the monastery.

    [Disclaimer: I don't have GIT Bash (in fact, I don't have Perl running on any MSWin platform).]

    The first thing I noticed was that your @INC contains paths with 'msys' and '5.8.8' but there's no mention of Strawberry Perl; however, the perldoc you're running is /c/strawberry/perl/bin/perldoc.

    I suspect this is your core problem: you'll need to use the GIT Bash version of perldoc. It's not really my area of expertise, but this may be related to the order of paths in $PATH. (If you can't work that out for yourself, I'm sure another monk can help with this.)

    Looking at the Core Pod::* modules for v5.8.8, I see many Pod::Perldoc::* modules but no specific Pod::Perldoc module. However, the latest Core Pod::* modules do include a specific Pod::Perldoc module.

    That would explain why Pod::Perldoc wasn't found in your @INC v5.8.8 paths.

    The perldoc code you posted is identical to mine (v5.18.1). Based on your error message and the documented v5.8.8 Core Pod::* modules, I'd expect a 5.8.8 version of perldoc to have different code (that didn't use Pod::Perldoc).

    -- Ken

Re: perldoc GIT bash
by bulk88 (Priest) on Mar 31, 2014 at 02:55 UTC
    Fix your PATH env var. You need to put C:\strawberry\someething ahead of "C:\Program Files\Git\bin". You are mixing 2 different perl installations across 2 very different versions of perl. You will have problems doing that.