8

Doesn't work with other modules, but to give an example. I installed Text::CSV_XS with a CPAN setting:

'makepl_arg' => q[PREFIX=~/lib],

When I try running a test.pl script:

$ perl test.pl

#!/usr/bin/perl

use lib "/homes/foobar/lib/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi";

use Text::CSV_XS;

print "test";

I get

Can't load '/homes/foobar/lib/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/Text/CSV_XS/CSV_XS.so' for module Text::CSV_XS: /homes/foobar/lib/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/Text/CSV_XS/CSV_XS.so: cannot open shared object file: No such file or directory at /www/common/perl/lib/5.8.2/i686-linux/DynaLoader.pm line 229.
at test.pl line 6
Compilation failed in require at test.pl line 6.
BEGIN failed--compilation aborted at test.pl line 6.

I traced the error back to DynaLoader.pm it happens at this line:

# Many dynamic extension loading problems will appear to come from
# this section of code: XYZ failed at line 123 of DynaLoader.pm.
# Often these errors are actually occurring in the initialisation
# C code of the extension XS file. Perl reports the error as being
# in this perl code simply because this was the last perl code
# it executed.

my $libref = dl_load_file($file, $module->dl_load_flags) or
    croak("Can't load '$file' for module $module: ".dl_error());

CSV_XS.so exists in the above directory

brian d foy
  • 129,424
  • 31
  • 207
  • 592
Tomasz
  • 5,269
  • 8
  • 56
  • 65
  • possible duplicate of [How can I use a new Perl module without install permissions?](http://stackoverflow.com/questions/251705/how-can-i-use-a-new-perl-module-without-install-permissions) – derobert Jan 31 '12 at 19:08

6 Answers6

5

When you installed the module, did you watch the output? Where did it say it installed the module? Look in lib. Do you see the next directory you expect?

Look in ~/lib to see where eveything ended up to verify that you have the right directory name in your use lib statement:

% find ~/lib -name CSV_XS.so

Once you see where it is installed, use that directory name in your use lib (or PERL5LIB or whatever).

I expect you have a lib/lib in there somehow. The PREFIX is just the, well, prefix, and the installer appends other directory portions to that base path. That includes lib, man, bin, etc.

Community
  • 1
  • 1
brian d foy
  • 129,424
  • 31
  • 207
  • 592
2

Try this instead:

'makepl_arg' => q[PREFIX=~/]

PREFIX sets the base for all the directories you will be installing into (bin, lib, and so forth.)

You may also be running into shell expansion problems with your '~'. You can try to expand it yourself:

'makepl_arg' => q[PREFIX=/home/users/foobar]

It would also be helpful if you included the commands you used to get the error you are asking about.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Frosty
  • 6,213
  • 3
  • 24
  • 20
2

Personally I would suggest to use local::lib. :)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Fayland Lam
  • 1,016
  • 8
  • 11
  • 30
    It would be very useful to provide here a few short commands that show how to use local::lib to install a module into a local library directory. – Chris Quenelle Jan 11 '13 at 19:30
  • 8
    Can you please explain *why* you suggested `local::lib`? What is it, and why is it better then the other solutions presented here? – Stefan Lasiewski Jan 02 '14 at 23:39
  • 2
    And how do we do that when: `Can't locate local/lib.pm in @INC ....` (and we can't install it, hence the need to install modules underneath one's homedir) – Olivier Dulac May 18 '17 at 14:06
1

It looks from the error message ("at /www/common ...") that your script is a CGI or mod_perl script. The web server is probably not running as the user 'foo', under whose home directory you've installed the module - that could result in the web server being unable to read that directory.

It may also be running in a "chroot jail", which would mean that the directory in which you've installed the module may not be visible to the script.

In other words, just because you can see the module, does not mean that the web server, and therefore your script, can do so. You should check the relevant file permissions, and if the server is chrooted, whether your module directory is mounted within the virtual file system.

Sherm Pendley
  • 13,556
  • 3
  • 45
  • 57
0

Does the file in question (CSV_XS.so) exist?

Does it exist at the listed location?

If you do:

set |grep PERL

What is the output?

Have you successfully installed other local perl modules?

Frosty
  • 6,213
  • 3
  • 24
  • 20
  • PERL5LIB='/homes/foobar/lib/perl5/site_perl/5.8.4/i686-linux:{HOME}/lib/perl5/site_perl/5.8.4' nope tried with Data::UUID, same problem – Tomasz Sep 19 '08 at 21:28
0

I strongly suggest installing your own perl in your own home directory, if you have space. Then you can keep everything under your control and keep your own module set, as well as escaping if the admins are keeping you on an older version of perl. (Not to mention preserving yourself if they upgrade some day and leave out all the modules you are relying on.)

skiphoppy
  • 97,646
  • 72
  • 174
  • 218