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

I'm trying to use Devel::Cycle and Devel::GC::Helper to profile some code

Its not working, because Perl can't load auto/DBI/

Looking into things, I've noticed that I have very few things in my Perl/VERSION/auto and Perl/VERSION/PLATFORM/auto folders.

Looking at various news postings on the net, many people seem to have a auto/DBI directory. I do not.

Can someone please explain to me what /auto/ is ? Is it autoloader compiled stuff? Is it some XS thing? Is there a setting in my cpan conf or something that can get DBI to compile stuff there?

update I actually do have an auto/dbi directory. that was a stupid mistake. it only has these files though: DBI.bundle DBIXS.h Driver.xst Driver +_xst.h Shell dbd_xsh.h dbi_sql.h dbipport.h + dbivport.h
and i still don't understand what auto is.

2006-08-20 Retitled by planetscape, as per Monastery guidelines: one-word (or module-only) titles hinder site navigation

( keep:0 edit:7 reap:0 )

Original title: '/auto/'

Replies are listed 'Best First'.
Re: What is the /auto/ directory used for?
by tilly (Archbishop) on Aug 19, 2006 at 18:22 UTC
    The /auto directory is used by code that uses AutoLoader to only load subroutines when they are actually used. See also AutoSplit.

    In this case it looks like you have an improperly installed module. From the function being accessed it is trying to implement some sort of tie. If I were to take a wild guess, I'd guess Tie::DBI. But that probably isn't right.

Re: What is the /auto/ directory used for?
by Joost (Canon) on Aug 19, 2006 at 18:08 UTC
Re: What is the /auto/ directory used for?
by syphilis (Bishop) on Aug 20, 2006 at 06:43 UTC
    Is the error "can't load" or "can't locate" ? For me, there is no such thing as the DBI::FIRSTKEY() function, hence:
    F:\pscrpt>perl -MDBI -e "DBI::FIRSTKEY()" Can't locate auto/DBI/ in @INC (@INC contains: ..


    Update: To explain a little further, in its attempts to find the DBI::FIRSTKEY() function, perl finally looks for that function in the file 'auto/DBI/'. That file doesn't exist, so perl informs us that it can't find that file. It would make better sense if perl told us that the DBI::FIRSTKEY() function did not exist (since that's what the real problem is).

      Yes, this error message sucks. It should list the two possible explanations with the most likely ("no such method") stressed more than the other ("*.al file missing because module not properly installed").

      Note that this error message is a result of over-use of inheritance. In particular, this line from

      @ISA = qw(Exporter DynaLoader);

      means that DBI "is a" Export and "is a" DynaLoader. Which means that if either Exporter or DynaLoad "is a" SomethingElse, then DBI also "is a" SomethingElse.

      So some implementation detail of Exporter or DynaLoader becomes the baggage of DBI because it declares itself to be a descendant of them. In this case, the detail is that one (or both) of them "is a" AutoLoader (or similar). So DBI suddenly acts like an AutoLoader even though it had no desire to do so.

      It would be better if Exporter and DynaLoader didn't use inheritance to get the AutoLoader functionality. And it would be better if DBI didn't use inheritance to get Exporter nor DynaLoader functionality.

      Note that this realization has lead to Exporter now supporting better ways for it to be used, such as:

      use Exporter qw( import );

      And note that some module authors have realized this problem with DynaLoader and worked around it similarly:

      require DynaLoader; # ... DynaLoader::bootstrap( __PACKAGE__ );

      It is rather sad that the OO mindset so often jumps to inheritance as the answer for nearly every problem. Here we have two important core modules that mostly just need to provide one subroutine to the modules that use them, yet they encourage inheritance to be used to accomplish this.

      It would be nice if DBI would fix this. Since DBI tries to be quite portable, it probably can't assume a modern version of Exporter, so it should instead use something like this:

      BEGIN { require Exporter; *import= \&Exporter::import; }

      Thus DBI would no longer produce this particularly misleading error message.

      - tye        

        Thus DBI would no longer produce this particularly misleading error message

        I couldn't get that to work ... I may well be missing something.

        I tried a variety of the changes you mentioned, but whenever I comment out (in "@ISA = qw(Exporter DynaLoader);" I get:
        F:\pscrpt>perl -MDBI -e "DBI::FIRSTKEY()" Can't locate object method "dl_load_flags" via package "DBI" at F:/per +lvc7/5.8.8/lib/ line 230. BEGIN failed--compilation aborted at F:/perlvc7/site/5.8.8/lib/ +line 262. Compilation failed in require. BEGIN failed--compilation aborted.

        And if I don't comment out that line of code in I always get:
        F:\pscrpt>perl -MDBI -e "DBI::FIRSTKEY()" Can't locate auto/DBI/ in @INC (@INC contains: F:/perlvc7/5 +.8.8/lib F:/perlvc7/site/5.8.8/lib F:/perlvc7/site/lib .) at -e line +1

        I guess a patch to would be one simple way for me to see exactly what is required. I'd like to know how to change this behaviour and still use DynaLoader. Digest::MD5 gets it right, but it uses XSLoader instead.

Re: What is the /auto/ directory used for?
by xdg (Monsignor) on Aug 20, 2006 at 16:31 UTC

    Not related to the problem at hand, but in answer to what /auto/ is for -- it can also be used to store module/distribution-specific shared files, such as templates, data, etc. See File::ShareDir for examples.


    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

      I should note also that the auto directory is specifically only for read-only files that are created at install-time, and not for any other sort of file. Once installed, nothing in auto will ever change.

      Although it was created originally for autosplit et al, the creation of File::ShareDir and related things has grown off this original purpose, as a place to put things that aren't libs, that are auto-generated or provided at install time.

      You may like to think of it as sort of like a Perl-specific platform-neutral version of /var/share on Unix.
        Not /var/share. /usr/share is for read-only access.
Re: What is the /auto/ directory used for?
by ysth (Canon) on Aug 20, 2006 at 17:04 UTC
    auto is a directory that files associated with a module (usually built during module installation) can go in. FIRSTKEY is a method used by hash ties, which DBI uses to support $handle->{foo} attribute access. Can you show some code?