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

Hi Friends, I got this error message- (Can't locate IO/Scalar.pm in @INC (@INC contains: /opt/rocks/lib/perl5/5.8.8/....)) when I run a program. However, the Scalar.pm is located in the '/opt/rocks/lib/perl5/5.8.8/IO/' directory and this directory is in the array @INC. Does anybody know what's wrong with it? Thanks! Dong
  • Comment on Can't locate IO/Scalar.pm in @INC (@INC contains: /opt/rocks/lib/perl5/5.8.8/

Replies are listed 'Best First'.
Re: Can't locate IO/Scalar.pm in @INC (@INC contains: /opt/rocks/lib/perl5/5.8.8/
by almut (Canon) on Apr 23, 2009 at 23:58 UTC

    What do you get with

    $ strace -efile perl -MIO::Scalar -e1 2>&1 | grep Scalar

    (strace would be for Linux)

      thanks, I got this following results: execve("/usr/bin/perl", "perl", "-MIO::Scalar", "-e1", /* 40 vars */) = 0 stat64("/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/IO/Scalar.pmc", 0xbf8b50bc) = -1 ENOENT (No such file or directory) stat64("/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/IO/Scalar.pm", 0xbf8b4fcc) = -1 ENOENT (No such file or directory) stat64("/usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi/IO/Scalar.pmc", 0xbf8b50bc) = -1 ENOENT (No such file or directory stat64("/usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi/IO/Scalar.pm", 0xbf8b4fcc) = -1 ENOENT (No such file or directory) stat64("/usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi/IO/Scalar.pmc", 0xbf8b50bc) = -1 ENOENT (No such file or directory) stat64("/usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi/IO/Scalar.pm", 0xbf8b4fcc) = -1 ENOENT (No such file or directory) stat64("/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/IO/Scalar.pmc", 0xbf8b50bc) = -1 ENOENT (No such file or directory) stat64("/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/IO/Scalar.pm", 0xbf8b4fcc) = -1 ENOENT (No such file or directory) stat64("/usr/lib/perl5/site_perl/5.8.8/IO/Scalar.pmc", 0xbf8b50bc) = -1 ENOENT (No such file or directory) stat64("/usr/lib/perl5/site_perl/5.8.8/IO/Scalar.pm", {st_mode=S_IFREG|0444, st_size=16737, ...}) = 0 open("/usr/lib/perl5/site_perl/5.8.8/IO/Scalar.pm", O_RDONLY|O_LARGEFILE) = 4 do you have any clue?

        The last line 'open(...) = 4' shows that IO/Scalar.pm is successfully opened (so, I suppose you don't get the "Can't locate..." error in this case when just plain loading nothing but the module).

        What do you get when you replace "perl -MIO::Scalar -e1" in the strace command with a call to your actual script that exhibits the problem? (Depending on how exactly you're calling the script (e.g. via shell wrapper), you might need the additional option -f to strace. In case of doubt, specify it anyway.)  Maybe the script itself is messing with @INC, or some such...  BTW, are you sure that you're using the same perl (i.e. /usr/bin/perl) to run the script?

Re: Can't locate IO/Scalar.pm in @INC (@INC contains: /opt/rocks/lib/perl5/5.8.8/
by roboticus (Chancellor) on Apr 23, 2009 at 23:38 UTC
    donghe:

    Sounds like a permissions problem. Is the user the code is running under actually have the required permissions to the directory and file?

    ...roboticus
      He also needs enough permissions to access ("x") every parent directory.
Re: Can't locate IO/Scalar.pm in @INC (@INC contains: /opt/rocks/lib/perl5/5.8.8/
by oeuftete (Monk) on Apr 23, 2009 at 23:51 UTC

    Probably not your problem, but you're not trying to require it without using a bareword, as described in require? I mention this possibility only because it bit me just minutes ago.

    Edit: That can't be it, or else you'd be seeing can't locate IO::Scalar (without the .pm). So consider this an off-topic Public Service Announcement.

      If he did, it would say

      Can't locate IO::Scalar in @INC

      but it says

      Can't locate IO/Scalar.pm in @INC

      so he did that right.

Re: Can't locate IO/Scalar.pm in @INC (@INC contains: /opt/rocks/lib/perl5/5.8.8/
by ikegami (Patriarch) on Apr 24, 2009 at 02:15 UTC

    Scalar.pm is located in the '/opt/rocks/lib/perl5/5.8.8/IO/' directory and this directory is in the array @INC.

    Is /opt/rocks/lib/perl5/5.8.8/ in @INC or just /opt/rocks/lib/perl5/5.8.8/IO/? It should be the former.

    (I think it was just a language error, but no harm in making sure.)

Re: Can't locate IO/Scalar.pm in @INC (@INC contains: /opt/rocks/lib/perl5/5.8.8/
by Anonymous Monk on Apr 24, 2009 at 02:34 UTC
    eval { require IO::Scalar; 1} or die "($@)($!)($^E)";
      i didn't use 'require', i use 'use IO::Scalar'
        That is test program, for debugging. Use it and post result