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

I'm just curious if anyone knows why "use lib 'foo'" doesn't automatically add foo/$Config{archname} as well. It's needed for XS modules that store things in the arch-specific path.
  • Comment on "use lib" and architecture-specific paths

Replies are listed 'Best First'.
Re: "use lib" and architecture-specific paths
by Errto (Vicar) on Aug 09, 2007 at 03:03 UTC
    According to lib:
    For each directory in LIST (called $dir here) the lib module also checks to see if a directory called $dir/$archname/auto exists. If so the $dir/$archname directory is assumed to be a corresponding architecture specific directory and is added to @INC in front of $dir.
    Does that not actually work under some circumstances? Does it require the auto subdir to exist? I confess to never having developed any arch-specific modules so I haven't tested it.
      Thanks, this was the nudge I needed. I looked at the code and saw that lib had a bug fix at some point in this section. The version 0.5564 doesn't do it properly for locally installed modules. It only works for the site_perl structure where the version number of perl is in the path. This was corrected in 0.5565.
Re: "use lib" and architecture-specific paths
by diotalevi (Canon) on Aug 09, 2007 at 02:59 UTC

    It's because of this that I've taken to unifying my arch and non-arch install targets. It's far more convenient to install things to a single location than to cope with lib's strangeness.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Re: "use lib" and architecture-specific paths
by Anonymous Monk on Aug 09, 2007 at 02:40 UTC
    Because its not perl, but DynaLoader/XSLoader who load such things.
      They have to be in @INC for it to work. If I add them manually, the XS modules work. And lib is not adding them.
Re: "use lib" and architecture-specific paths
by FunkyMonk (Bishop) on Aug 09, 2007 at 09:11 UTC
    Surely it isn't needed. I don't have any architecure specific directories in my @INC.

      Seriously? I've never seen an @INC on any machine that didn't have them. If you have any XS modules (DBI, HTML::Parser) you need them.
        I looked a lttle harder and it seems the arch dirs are defined to be the same as non-archdirs (this is Debian Testing, BTW):

        perl -V (with snippage):

        Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Platform: osname=linux, osvers=2.6.18-1-amd64, archname=x86_64-linux-gnu-thr +ead-multi uname='linux gkar 2.6.18-1-amd64 #1 smp sat oct 21 18:36:02 cest 2 +006 x86_64 \ gnulinux ' config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN \ -Dcccdlflags=-fPIC -Darchname=x86_64-linux-gnu -Dprefix=/usr \ -Dprivlib=/usr/share/perl/5.8 -Darchlib=/usr/lib/perl/5.8 \ -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr +/lib/perl5 \ -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.8.8 \ -Dsitearch=/usr/local/lib/perl/5.8.8 -Dman1dir=/usr/share/man/man1 @INC: /home/zippy/scripts/lib /etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl .

Re: "use lib" and architecture-specific paths
by Anonymous Monk on Aug 09, 2007 at 01:46 UTC
    Its not needed
      If you install an XS module in a private location, it does seem to be needed. Adding "~/perl-lib/" via "use lib" didn't cause it to search ~/perl-lib/i686-linux/ automatically.