Re: How to change @INC permanently?
by merlyn (Sage) on Aug 24, 2005 at 04:11 UTC
|
It's in the binary of /usr/bin/perl. Either recompile Perl, or carefully edit the binary (not necessarily possible if you need to add path items).
| [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] [d/l] |
|
|
|
Re: How to change @INC permanently?
by techra (Pilgrim) on Aug 24, 2005 at 13:57 UTC
|
And yet another solution is to make use of the myriad paths that Perl scans for modules in.
</p
Notice that Perl scans /etc/perl by default. Most distributions of Linux don't put anything there, so why not just softlink the directory structure your modules live under into /etc/perl?
| [reply] [Watch: Dir/Any] |
|
$ perl -e 'print join "\n",@INC'
/etc/perl
/usr/local/lib/perl/5.8.7
/usr/local/share/perl/5.8.7
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.8
/usr/share/perl/5.8
/usr/local/lib/site_perl
/usr/local/lib/perl/5.8.4
/usr/local/share/perl/5.8.4
on RH perl 5.8.0
$ perl -e 'print join "\n",@INC'
/usr/lib/perl5/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/5.8.0
on solaris perl 5.00503
> perl -e 'print join "\n",@INC'
/usr/perl5/5.00503/sun4-solaris
/usr/perl5/5.00503
/usr/perl5/site_perl/5.005/sun4-solaris
/usr/perl5/site_perl/5.005
| [reply] [Watch: Dir/Any] [d/l] [select] |
Re: How to change @INC permanently?
by AJRod (Scribe) on Aug 24, 2005 at 15:46 UTC
|
If you have theoretically the power to change @INC permanently on your system, wouldn't you also have the power to more simply reinstall the module in a place defined by @INC? | [reply] [Watch: Dir/Any] |
|
As root, yes. However, I make an effort to avoid being root whenever possible, because bad things can (and do) happen when I'm root. I'm way too familiar with reinstalling Linux, because of playing around as root...
| [reply] [Watch: Dir/Any] |
|
It's a good practice to avoid being root if you can. I just use sudo and get the same results with a safety net. You can either run the CPAN shell using sudo to install things or use sudo on the final install step for a manual install.
perl Makefile.PL
make
make test
sudo make install
That will put the new modules in the places perl expects and make them available for everyone and you don't need to log in as root. | [reply] [Watch: Dir/Any] [d/l] |
Re: How to change @INC permanently?
by z3d (Scribe) on Aug 24, 2005 at 17:00 UTC
|
You'll need to rebuild perl (and libperl if it was built separately). Here's an example snippet of the patch used by a distro i work with:
--- perl.c.orig 2005-07-26 13:04:54.000000000 -0400
+++ perl.c 2005-07-26 13:05:05.000000000 -0400
@@ -4397,9 +4397,9 @@ S_init_perllib(pTHX)
incpush(APPLLIB_EXP, TRUE, TRUE, TRUE);
#endif
-#ifdef ARCHLIB_EXP
- incpush(ARCHLIB_EXP, FALSE, FALSE, TRUE);
-#endif
+ /* for configuration where /usr is mounted ro (CPAN::Config, Net:
+:Config) */
+ incpush("/etc/perl", FALSE, FALSE, TRUE);
+
#ifdef MACOS_TRADITIONAL
{
Stat_t tmpstatbuf;
"I have never written bad code. There are merely unanticipated features."
| [reply] [Watch: Dir/Any] [d/l] |
Re: How to change @INC permanently?
by johnnywang (Priest) on Aug 24, 2005 at 23:07 UTC
|
| [reply] [Watch: Dir/Any] |
Re: How to change @INC permanently?
by Anonymous Monk on Mar 26, 2007 at 14:08 UTC
|
I see that there are a lot of people wanting to know how to add directories to their @INC permanently.
I accomplished this by adding the following line to the end of my startup.pl file: push(@INC, "Put path to directory here");
Restart apache and you should be good to go! Hope this helps.
| [reply] [Watch: Dir/Any] |