Re: Personal library with CPAN
by Zaxo (Archbishop) on Jun 07, 2004 at 05:55 UTC
|
Copy the system CPAN::Config module to ~/.cpan/CPAN/MyConfig.pm and edit it to provide your own build paths and make directives, particularly the installation prefix directory.
You will probably want to set up the PERL5LIB environment variable to let perl find your private installations.
Update: Some adaptation of this sequence of commands will set you up (tested):
$ mkdir ~/.cpan
$ mkdir ~/.cpan/CPAN
$ cd ~/.cpan/CPAN
$ cp /usr/lib/perl5/5.8.4/CPAN/Config.pm MyConfig.pm
$ perl -pi -e's!/root/\.cpan!$ENV{HOME}/.cpan!' MyConfig.pm
$ perl -pi -e'/makepl_arg/ && s!\]! PREFIX=$ENV{HOME}]!' MyConfig.pm
$ echo "export PERL5LIB=${HOME}/lib/perl5/site_perl/5.8.4/i686-linux:$
+{HOME}/lib/perl5/site_perl/5.8.4" >> ~/.bash_profile
$ . ~/.bash_profile
$ perl -MCPAN -e shell
That should be all you need to do, as long as the system CPAN setup is similar enough and your shell bash enough.
| [reply] [Watch: Dir/Any] [d/l] |
|
How do you know this?
MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!" | I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README). | ** The third rule of perl club is a statement of fact: pod is sexy. |
| [reply] [Watch: Dir/Any] |
|
It's in the, uhhh.., Pod ;-). perldoc CPAN, way down in the "Configuration" section, around page 14 on this terminal.
| [reply] [Watch: Dir/Any] |
|
|
With a modern version of CPAN you can use the command mkmyconfig in the
CPAN shell. This will create your own ~/.cpan/CPAN/MyConfig.pm
| [reply] [Watch: Dir/Any] [d/l] |
|
Since which version of CPAN?
| [reply] [Watch: Dir/Any] |
|
|
Hi Zaxo,
The lists of command you provided works great.
The really nice things about that set-up is that:
1. You can call the module without having to invoke
the standard "use lib" command.
2. You can call the perldoc of the modules installed locally from anywhere.
All these happen JUST as it was installed internally as ROOT! It's incredible.
Would you mind explain which part of the command above that does that? I can somehow guess, but not sure.
| [reply] [Watch: Dir/Any] |
|
Line seven sets and exports the environment variable PERL5LIB in the bash login shell configuration. That is the part which tells Perl where else to look for modules. Technically, Perl adds the path in $PERL5LIB to @INC. The perlrun and perlvar docs tell all.
The following line sources ~/.bash_profile in the current shell so that Perl has the benefit of PERL5LIB right away. That amounts to rereading the shell config.
That may fail to influence a web server's Perl environment. If it does, you can use the SetEnv directive in .htaccess or the server configuration for regular cgi scripts. I think PerlSetEnv should work for mod_perl, but mod_perl usually implies enough control that a private perl lib is unnecessary, so I've never tried that setup.
| [reply] [Watch: Dir/Any] |
|
/usr/local/bin/perl -p -e "s/~DRIVER~/Perl/g" ./Driver.xst > Perl.xsi
/usr/local/bin/perl /usr/local/lib/perl5/5.8.0/ExtUtils/xsubpp -typem
+ap /usr/local/lib/perl5/5.8.0/ExtUtils/typemap -typemap typemap Perl
+.xs > Perl.xsc && mv Perl.xsc Perl.c
cc -c -DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.0/BSDPAN" -DHAS_FPSET
+MASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -I/usr/local/include
+-O -pipe -DVERSION=\"1.50\" -DXS_VERSION=\"1.50\" -DPIC -fPIC "-I
+/usr/local/lib/perl5/5.8.0/mach/CORE" -W -Wall -Wpointer-arith -Wbad
+-function-cast -Wno-comment -Wno-sign-compare -Wno-cast-qual -DDBI_NO
+_THREADS Perl.c
cc: permission denied
*** Error code 126
Stop in /usr/home/sites/www.whereever.com/whereever/.cpan/build/DBI-1.
+50.
/usr/bin/make -- NOT OK
Running make test
Can't test without successful make
Running make install
make had returned bad status, install seems impossible
I'll continue to search perlmonks, but i think this might just be a permission setting that is obvious to real unix hackers ;)
| [reply] [Watch: Dir/Any] [d/l] |
|
Yes, that appears to be a permission problem with -DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.0/BSDPAN". If you need a private cpan directory, you probably don't have write permission there.
I don't know if this is the source of the problem, but sometimes authors hardcode paths that they should let CPAN.pm figure out. You could try setting and exporting APPLIB_EXP before the build as a workaround.
| [reply] [Watch: Dir/Any] |
|
I just noticed that with the last two releases of ExtUtils::MakeMaker, it looks like INSTALL_BASE is now preferred usage, and --install-base is preferred for Module::Build. (See the latest ExtUtils::MakeMaker::FAQ.) If so, your PERL5LIB will change slightly as will the buildpl_arg in MyConfig.pm.
| [reply] [Watch: Dir/Any] |
|
Dear Zaxo,
I had my CPAN installation setting following your
ingenious solution above. I never has compilation
problem beforehand when running a Perl script (*.pl).
Recently, while trying a CGI script like below (let's call it 'test.cgi').
I had problem compiling it.
#!/usr/bin/perl -w
use CGI ':standard';
use Mail::Sendmail;
Although Mail::Sendmail is successfuly installed,
my CGI script can't recognize the location. I encounter
this strange result.
When I run this:
$ perl -c test.cgi
# it gives
test.cgi syntax OK
But when I run this with taint:
$ perl -cT test.cgi
It gives:
Can't locate Mail/Sendmail.pm in @INC (@INC contains: ~/lib/perl5/site
+_perl/5.8.5/ /usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/pe
+rl5/5.8.5 /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr
+/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/sit
+e_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.2/i
+386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.1/i386-linux-thre
+ad-multi /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/
+lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4 /usr/lib/per
+l5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2 /usr/lib/perl5/site
+_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /
+usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl
+5/vendor_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/vendor_per
+l/5.8.3/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.2/i386
+-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-threa
+d-multi /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr
+/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4 /usr/li
+b/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2 /usr/lib/p
+erl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl
+5/vendor_perl) at temp.cgi line 4.
BEGIN failed--compilation aborted at temp.cgi line 4.
How can I have my cgi script recognize the location of the library? I also tried
using "use lib" construct like this:
but also gives the same symptom.
Does it has anything to do
to the way I install the module following your approach?
Update:
That may fail to influence a web server's Perl environment. If it does, you can use the SetEnv directive in .htaccess or the server configuration for regular cgi scripts.
Just realized you mentioned about the problem above. But how do you actually "SentEnv directive of server config" in my cgi scripts?
| [reply] [Watch: Dir/Any] [d/l] [select] |
|
SetEnv PERL5LIB /where/the/mods/are/:/where/else/lib
The web server must be able to read files in those directories, of course. Apache suExec is a great help with that, for security's sake.
See the apache httpd manual for variations that might be handy. When mod_perl is involved, I believe PerlSetEnv is needed, but I've never tried that.
| [reply] [Watch: Dir/Any] [d/l] |
|
|
|
Dear Zaxo,
How can I make your setting above workable in Mac OSX?
Have you ever try it?
I can't seem to find proper "Config.pm" in /
This is all I have.
./System/Library/Perl/5.8.8/darwin-thread-multi-2level/Config.pm
./System/Library/Perl/5.8.8/darwin-thread-multi-2level/Encode/Config.p
+m
./System/Library/Perl/5.8.8/ExtUtils/MakeMaker/Config.pm
./System/Library/Perl/5.8.8/Net/Config.pm
./System/Library/Perl/Extras/5.8.8/darwin-thread-multi-2level/ModPerl/
+Config.pm
./System/Library/Perl/Extras/5.8.8/Module/Build/Config.pm
| [reply] [Watch: Dir/Any] [d/l] |
Re: Personal library with CPAN
by osunderdog (Deacon) on Jun 07, 2004 at 14:19 UTC
|
perl Makefile.PL PREFIX=/home/username
then
make install
The package will be installed starting at /home/username rather than the standard location. | [reply] [Watch: Dir/Any] [d/l] [select] |
|
PERL5LIB should be also adjusted:
env PERL5LIB=/home/username/lib/perl perl Makefile.PL PREFIX=/home/use
+rname
(not sure about the exact PERL5LIB value, might be something with perl5 instead).
| [reply] [Watch: Dir/Any] [d/l] |
Re: Personal library with CPAN
by schweini (Friar) on Jun 07, 2004 at 22:42 UTC
|
do the proposed solutions work for XS stuff like Tk or DBD::mysql?
i.e.: can i do this, and then simply copy the CPAN directoy between compatible (x86 with same distro) machines without having to re-install all them modules everywhere? | [reply] [Watch: Dir/Any] |
|
Not necessarily. Check that this value is the same:
"perl -V:archname"
For example, on my current machine, the value is:
i386-freebsd-64int
However, another FreeBSD box running the same OS version might not be 64 bit, so the answer would be:
i386-freebsd
| [reply] [Watch: Dir/Any] [d/l] [select] |