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

Hello, I am installing a Perl autoresponder script in my cgi-bin with a script called install.cgi and I get this error:
Software error: Can't locate conf.cgi in @INC (@INC contains: lib /usr/local/lib64/per +l5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/per +l5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) at install.cgi line + 14. For help, please send mail to the webmaster...
My issue is that there actually is a directory called "lib" as stated above in the error message: " @INC contains: lib " and the necessary perl modules are located there. I even tried using:
use FindBin; use lib "$FindBin::RealBin/..";
and what that did is print the whole path to the parent dir within the error message, and install.cgi just won't execute. Any suggestions? Thanks, Carlos

Replies are listed 'Best First'.
Re: Can't locate conf.cgi in @INC
by kcott (Bishop) on Nov 24, 2020 at 01:28 UTC

    G'day Carlos,

    I'd be reasonably certain your problem is that the directory 'lib' is not tied to an absolute path. Note how all the other @INC paths start with /usr/....

    I can emulate your problem like this.

    Create a directory called ~/tmp/pm_11124087/lib and add this module to it:

    $ cat ~/tmp/pm_11124087/lib/ package XYZ; 1;

    In ~/tmp/pm_11124087, create this script:

    $ cat ~/tmp/pm_11124087/ #!/usr/bin/env perl use strict; use warnings; use lib 'lib'; use XYZ;

    If I run that script from ~/tmp/pm_11124087, all is good:

    $ ./ $

    However, if I go up one directory:

    $ cd .. $ pm_11124087/ Can't locate in @INC (you may need to install the XYZ module) ( +@INC contains: lib /home/ken/...

    So that's basically your problem reproduced.

    I think you were on the right track with FindBin but left off the 'lib' directory. I can fix my problem like this:

    $ cat ~/tmp/pm_11124087/ #!/usr/bin/env perl use strict; use warnings; use FindBin; use lib "$FindBin::Bin/lib"; use XYZ;

    So the earlier issues go away:

    $ ./ $ cd .. $ pm_11124087/ $

    I don't know what your directory structure is: you may need to adjust the path in use lib "$FindBin::Bin/lib"; to suit your setup.

    You reported you checked for the existence of 'lib'. You should also check that conf.cgi is actually in that directory and that you have appropriate permissions to access both the directory and the file. Given your initial report included "webmaster", those permissions may relate to your web server, not your personal permissions; e.g. user web needs read permission, not just user carlos.

    See also: FindBin and lib.

    — Ken

      Thanks Ken,

      I kept searching for a solution and found that "require" should use a full path, so for conf.cgi I used:

      require '/home/myhost/public_html/cgi-bin/mlm/conf.cgi';

      and that solved the problem.