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

... 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.

  • Comment on Re: Can't locate loadable object for module X in @INC (@INC contains: ... )
  • Download Code

Replies are listed 'Best First'.
Re^2: Can't locate loadable object for module X in @INC (@INC contains: ... )
by arthurg (Acolyte) on Nov 17, 2009 at 15:59 UTC

    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

        If you're on a typical UNIX/Linux box, the loaction of these lib modules is controlled by LD_LIBRARY_PATH. Search your relavant perl dirs for .so file Unix or .dll Windows, and make sure these dirs are included. Typically it's export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:...FULL PATHS. ESPCIALLY NOTE, that these are probably not in INC, just the executables will be there.
Re^2: Can't locate loadable object for module X in @INC (@INC contains: ... )
by Anonymous Monk on Aug 14, 2014 at 23:56 UTC
    "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.
        Yeah, that is never the case ... whenever you see XSLoader or DynaLoader, thats where the meat of the module lives, you can't simply comment it out, it makes no sense (the module won't work)