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

This may seem trivial, but it is something that I have wondered about for a while.

I have to install perl modules in my user directory, so I use perl Makefile.PL prefix=/home/ajdelore.

What I have noticed is that they seem to get installed in two different directories, seemingly without any reason:

/home/ajdelore/lib/perl5/site_perl/5.005
/home/ajdelore/lib/perl5/5.00502

Is there a reason for this? What is the difference between the two directories? Does the installdirs flag have anything to do with it?

Also, I have sub-directories in the above called auto/, sun4-solaris/, and sun4-solaris/auto/ that seem to contain empty sub-directories named after installed modules. What is going on here?

</ajdelore>

Replies are listed 'Best First'.
Re: Location of perl libraries under unix
by belg4mit (Prior) on Jul 16, 2003 at 19:59 UTC
    Any module you install yourself should go to site_perl, that's the meaning. Site specific modules (as opposed to core modules that come with perl). auto directories are used by the Autoloader module for segmented modules, they often contain 0-length *.bs (bootstrap) files. You get you architecture-platform module directories as well for dynamic libraries. Yours is sun4-solaris. Your home might be on a nettwork share such as mine, and linux on x86 surely couldn't use the binaries built for a sun (wheras pure perl modules can be shared and are not stored under an arch-sys dir).

    --
    I'm not belgian but I play one on TV.

Re: Location of perl libraries under unix
by richardX (Pilgrim) on Jul 16, 2003 at 23:08 UTC
    I use a hosted web site and they do not have CPAN modules installed. So I have to install them myself. Here is my workaround so far (an example):

    perl -MCPAN -e 'install File::Spec'

    cd /home/my_home_path/.cpan/build/File-Spec-0.82

    perl Makefile.PL PREFIX=/home/my_home_path/.cpan/CPAN INSTALLDIRS=site INSTALLSITELIB=/home/my_home_path/.cpan/CPAN

    make

    make test

    make install

    I then add the following code to my Perl scripts:

    BEGIN { unshift(@INC,"/home/my_home_path/.cpan/CPAN"); }

    This BEGIN code at the beginning of the script allows me to not change the paths of all my modules.

    Richard

    There are three types of people in this world, those that can count and those that cannot. Anon

      Interesting solution... I suppose that installdirs=(site||perl) would dictate whether the installation goes into lib/perl/site_perl/5xxxx or lib/perl/5xxxx.

      I don't quite understand how my CGI works, as they have some kind of secure set-up. It uses a completely different server, and requires scripts to be permitted 700. I can't determine if it runs as me or if it runs as nobody, and if it runs as me it seems equivocal wether it picks up my PERLLIB environment or not.

      Of course, as soon as I write that I realize that I could write a cgi script to find that out rather quickly...

      What I have done in the past is create symlinks to the required modules from the CGI directory to my LIB directory, and this seems to work fine.

      Perhaps the BEGIN block would be more appropriate...

      </ajdelore>

      According to 'perldoc lib':

      use lib LIST;

      is almost the same as saying:

      BEGIN { unshift(@INC, LIST) }

      The only difference is that, for each directory in the list, it checks for an architecture specific directory below. So, you've definitely hit on the right idea, but I think
      use lib '/home/my_home_path/.cpan/CPAN'; is a little cleaner.

      The other thing that might help is that you can configure CPAN to automate the exact sequence you describe. Run perl -MCPAN -e shell and do the following:

      o conf makepl_arg 'PREFIX=your_path_here INSTALLDIRS=site INSTALLSITELIB=your_path_here' (That's a lowercase 'o', not a bullet point)
      o conf on its own will show you your current conf(iguration) options.
      makepl_arg defines the options that will be passed after perl Makefile.PL

      Then, in the interactive shell, install File::Spec would be equivalent to the commands you listed above.

Re: Location of perl libraries under unix
by benizi (Hermit) on Jul 16, 2003 at 20:59 UTC
    I ran into a similar "problem" under a CGI server I run scripts on. It's annoying to have to use lib '/home/benizi/perllib'; and use lib '/home/benizi/perllib/site_perl';.

    My work-around was to use the LIB parameter when compiling modules, rather than PREFIX.

    perl Makefile.PL lib=/home/benizi/perllib

    A lot of stuff still gets put into /home/benizi/perllib/sun4-solaris, but use lib 'DIR' takes care of that detail, adding both "DIR/sun4-solaris" and "DIR" to @INC. I also get errors about permissions when 'make install' tries to install documentation (the install location of man pages is unaffected by LIB), but they're (rightly) ignored in the process. And I don't do any of this manually: I set up CPAN to pass 'lib=/home/benizi/perllib' as 'makepl_arg'. (in a CPAN shell, type o conf makepl_arg "lib=/home/benizi/perllib")