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

Hi !

I wrote a CGI Perl program that used to run well on my machine. I had to install it on another machine : same linux OS and same server...
But on this other pc I have this error message on my browser when trying to use the program :
"can't locate CGI.pm in @INC" ...

Any idea ?

thanks !

Replies are listed 'Best First'.
Re: can't locate CGI.pm ...
by blue_cowdawg (Monsignor) on Apr 08, 2004 at 18:27 UTC

        same linux OS and same server...

    I would not assume that both environments are identical vincentberenz. The symptomology you are reporting can be caused by:

    • Non standard installation of Perl (in other words CGI has been stripped out of it)
    • @INC being screwed up somehow
    • File/directory permissions are hosed.
    If you aren't empowered with priveleged access on the box team up with your friendly SysAdmin and either re-install Perl or figure out what's broke with what you have.

      I've seen those symptoms when (in the name of security) the hoster moves the apache into chroot, then installs just what he thinks he needs into that chroot.

      I even had to deal with that once, running the script, seeing what broke, copying the missing file from the normal install into the chroot, running the script (lather, rinse, repeat).

      The hoster insisted this was the only way to have his apache instalation as secure as possible. Of course, three weeks later, his boss wanted a web-based forum - and that beast needed a whole bunch of modules, so the guy cd'ed into the chroot and installed the complete perl there. Seems perl wasn't so dangereous when he had to work with it.

            I've seen those symptoms when (in the name of security) the hoster moves the apache into chroot, then installs just what he thinks he needs into that chroot.

        Thanks for reminding me. I ran into that once too. Most service providers don't do that anymore but use virtual hosts instead.

Re: can't locate CGI.pm ...
by b10m (Vicar) on Apr 08, 2004 at 17:15 UTC

    You didn't install CGI on that "other machine" ?

    --
    b10m

    All code is usually tested, but rarely trusted.
      Oh, I just configurated the server (a jakarta one, "renametojar" files names to change and web.xml to modify). Perl is although installed on that machine. Is there something else to do ????
Re: can't locate CGI.pm ...
by davido (Cardinal) on Apr 08, 2004 at 17:59 UTC
    Strange, since CGI.pm is part of the core Perl distribution, IIRC. Does your system's administrator have anything to say on the subject?

    You can type at the command line, perl -V and you'll get a listing of a lot of configuration things, including the contents of @INC. That'll let you know if there's a problem with the INC paths.

    Also, what do you find when you look in perl/lib and perl/site/lib for CGI.pm? Is it there?


    Dave

      Thanks for your answer ...

      I typed perl -v and here what I have for the @INC :

      /usr/lib/perl5/5.8.0/i386-linux-thread-multi
      /usr/lib/perl5/5.8.0/
      /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
      /usr/lib/perl5/site_perl/5.8.0/
      /usr/lib/perl5/site_perl
      /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
      /usr/lib/perl5/vendor_perl/5.8.0
      /usr/lib/perl5/5.8.0/i386-linux-thread-multi
      /usr/lib/perl5/5.8.0

      I although used the "find" command to look for CGI.pm but I did not find it !