Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Can't locate loadable object for module X in @INC (@INC contains: ... )

by arthurg (Acolyte)
on Nov 17, 2009 at 02:34 UTC ( [id://807603]=perlquestion: print w/replies, xml ) Need Help??

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

use X; produces this message. Perl's documentation defines use as
BEGIN { require Module; Module->import( LIST ); }
and says that require "Has semantics similar to the following subroutine":
sub require { my ($filename) = @_; if ( exists $INC{$filename} ) { return 1 if $INC{$filename}; die "Compilation failed in require"; } my ( $realfilename, $result ); ITER: { foreach $prefix (@INC) { $realfilename = "$prefix/$filename"; if ( -f $realfilename ) { $INC{$filename} = $realfilename; $result = do $realfilename; last ITER; } } die "Can't find $filename in \@INC"; } if ($@) { $INC{$filename} = undef; die $@; } elsif ( !$result ) { delete $INC{$filename}; die "$filename did not return true value"; } else { return $result; } }

Given this, what does "Can't locate loadable object for module X in @INC (@INC contains: ... )" mean? That is, which of the errors that require can return will return it?

BTW, a comprehensive repository of Perl core error messages would be great.

Thanks

Arthur

Replies are listed 'Best First'.
Re: Can't locate loadable object for module X in @INC (@INC contains: ... )
by chromatic (Archbishop) on Nov 17, 2009 at 04:15 UTC
    ... what does "Can't locate loadable object for module X in @INC (@INC contains: ... )" mean?

    It means that the module has a shared library component (an .so, .dylib, or DLL, depending on your platform) that DynaLoader couldn't load. Usually this happens because of an installation error such as copying .pm files from the installation directory to the installed directory and neglecting to build or copy the binary components.

    ... a comprehensive repository of Perl core error messages would be great.
    See perldiag or use the splain utility.

      Thanks, chromatic, that's helpful.

      I still believe that a comprehensive repository of Perl core error messages would be great.

      This particular case provides 3 reasons:

      1. the error "Can't locate loadable object for module X in @INC" is not fully explanatory. I.e., it doesn't say which object it cannot locate.

      2. perldiag doesn't mention this error.

      3. splain is misleading at best, and arguably wrong:

      (F) You said to do (or require, or use) a file that couldn't be found. Perl looks for the file in all the locations mentioned in @INC, unless the file name included the full path to the file. Perhaps you need to set the PERL5LIB or PERL5OPT environment variable to say where the extra library is, or maybe the script needs to add the library name to @INC. Or maybe you just misspelled the name of the file. See perlfunc/require and lib.

        I still believe that a comprehensive repository of Perl core error messages would be great.

        Its called perldiag.

        it doesn't say which object it cannot locate.

        Um, the one for module X :D

        C:\> perl -e"package Foo; use base qw! DynaLoader !; bootstrap Foo;" Can't locate loadable object for module Foo in @INC (@INC contains: C: +/perl/5.10.1/lib/MSWin32-x86-multi-thread C:/perl/5.10.1/lib C:/perl/ +site/5.10.1/lib/MSWin32-x86-multi-thread C:/perl/site/5.10.1/lib .) a +t C:/perl/5.10.1/lib/MSWin32-x86-multi-thread/DynaLoader.pm line 103 DynaLoader::croak('Can\'t locate loadable object for module Fo +o in @INC (@INC co...') called at C:/perl/5.10.1/lib/MSWin32-x86-mult +i-thread/DynaLoader.pm line 170 DynaLoader::bootstrap('Foo') called at -e line 1
        Technically its looking for "Foo$Config{dlext}", so maybe the error message should actually spell that out?

        2. perldiag doesn't mention this error.

        Yes it does

        C:\>perldoc perldiag |grep -C2 "loadable object" the file, say, by doing "make install". Can't locate loadable object for module %s in @INC (F) The module you loaded is trying to load an external librar +y, like for example, "foo.so" or "bar.dll", but the DynaLoader mo +dule

        3. splain is misleading at best, and arguably wrong:

        Hmm, looks incomplete, I think you found a bug, you should report it

      "Usually this happens because of an installation error such as copying .pm files from the installation directory to the installed directory and neglecting to build or copy the binary components." ...yes, well, how is this done? For RedHat would be great... thanks
        If the error is caused by copying a module file from the installation tree without doing a make/install then you may be able to resolve the error by finding the file in the library directory and editing it. Then look for a line such as
        require XSLoader; XSLoader::load('Error:Casing:Module', $VERSION);
        and removing or commenting out these lines. If there are no object dependencies then this may at least get you up and running again.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://807603]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-20 15:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found