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

I have Perl installed in my home directory. My username just changed, so my home directory path is changed to reflect my new username. Now my installed perl doesn't work anymore, because it can't find the paths in its compiled @INC settings.

Changing the path tokens in all the installed files (e.g. Config.pm, Config_heavy.pl, etc.) doesn't help. I presume the @INC paths are compiled into the binary?

Any tricks to re-targeting an already built Perl installation?

thanks,
-Cadphile...

Replies are listed 'Best First'.
Re: can I move an installled Perl build?
by Tanktalus (Canon) on Oct 27, 2011 at 23:08 UTC

    I changed my user ID on my home machine many years ago as matching the userID I have at $work makes working from home so much easier. (I also match the UID for the same reason.) To keep stuff working, I had a symlink with the old home directory pointing to the new one for many years (I think I got rid of it a year or so ago). This allows you to keep working with the least amount of effort, and to make changes to match the new path over a longer period of time.

    This assumes, of course, that your sysadmin will allow it. Barring the BOFH, I think this is a reasonable request. Good luck!

Re: can I move an installled Perl build?
by JavaFan (Canon) on Oct 28, 2011 at 01:08 UTC
    Since you've installed perl in your home directory, I presume you're using it to run scripts from the command line. Putting a export PERL5LIB="....", with .... the directories your libraries are in ought to do the trick.

    There are directories compiled into the binary (assuming a normal build), but they are only used as defaults. It's actually fine if they don't exist (think about it, when running the test suite between building and installing perl, the directories compiled in don't exist yet either).

Re: can I move an installled Perl build?
by Anonymous Monk on Oct 27, 2011 at 22:51 UTC
    $ grep -iC1 relocatable INSTALL
    
    =head2 Relocatable @INC
    
    To create a relocatable perl tree, use the following command line:
    
        sh Configure -Duserelocatableinc
    
    --
    can be configured on a per-directory basis, although the default with
    "-Duserelocatableinc" is that everything is relocated. The initial
    install is done to the original configured prefix.
    
    $ grep -iC1 Would.*relocatable  Configure
    
    Would you like to build Perl so that the installation is relocatable, so that
    library paths in @INC are determined relative to the path of the perl binary?
    
Re: can I move an installled Perl build?
by runrig (Abbot) on Oct 27, 2011 at 22:56 UTC
    Yes, it's compiled in (e.g., run strings /path/to/your/perl). I think I once changed it by carefully editing the perl binary (IIRC, the length of each path must be the same or less), and then editing the Config.pm file, but Buyer Beware and YMMV. I recommend recompiling.

      I found this in CPAN, and a similar script in ActiveState (reloc_perl):

      PPM::RelocPerl.pm

      It does a binary edit, as you said...

      Can't link homedir -- don't have root on server

      The -Duserelocatableinc option is interesting... have to think about how to best use relative paths in @INC.
      Probably can just use a wrapper to set the calling directory...

      I think I'll just recompile everything...
      probably easier in the long run!

      thanks,
      -Cadphile

Re: can I move an installled Perl build?
by Anonymous Monk on Oct 28, 2011 at 00:52 UTC

    Hi,

    I have a Perl installation on a flash drive ( Windows ActiveState ) which was actually created on the C drive of a Windows XP machine and copied onto the flash drive.

    When I get to where I am going to use it I run a bat file containing :

    SET PATH=%PATH%;%1:\Perl;%1:\Perl\BIN;%1

    like this : setpath drive_letter

    I haveto do this because they don't like people changing the Path using the Windows solution.

    This works fine for me on XP and w7.

    J.C.