Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Can't locate conf.cgi in @INC

by CarlosN (Initiate)
on Nov 23, 2020 at 22:20 UTC ( #11124087=perlquestion: print w/replies, xml ) Need Help??

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/XYZ.pm package XYZ; 1;

    In ~/tmp/pm_11124087, create this script:

    $ cat ~/tmp/pm_11124087/test_lib.pl #!/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:

    $ ./test_lib.pl $

    However, if I go up one directory:

    $ cd .. $ pm_11124087/test_lib.pl Can't locate XYZ.pm 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/test_lib.pl #!/usr/bin/env perl use strict; use warnings; use FindBin; use lib "$FindBin::Bin/lib"; use XYZ;

    So the earlier issues go away:

    $ ./test_lib.pl $ cd .. $ pm_11124087/test_lib.pl $

    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.

      Carlos

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11124087]
Approved by GrandFather
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2021-01-18 01:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?