I use perlbrew
to manage my Perl environment.
When I installed perlbrew
the first time as per the documentation, it installed everything to ~/perl5/perlbrew
, which I now find undesirable.
The documentation states:
The directory ~/perl5/perlbrew will contain all install perl executables, libraries, documentations, lib, site_libs. In the documentation, that directory is referred as "perlbrew root". If you need to set it to somewhere else because, say, your HOME has limited quota, you can do that by setting PERLBREW_ROOT environment variable before running the installer:
export PERLBREW_ROOT=/opt/perl5/perlbrew curl -kL http://install.perlbrew.pl | bash
Question: How can I move PERLBREW_ROOT
directory to be /opt/perl5/perlbrew
instead of ~/perl5/perlbrew
?
Unfortunately, you cannot simply move an installed Perl. For starters, the paths added to @INC
are hardcoded. I present you four solutions, of which I recommend the third.
But first, I recommend using /opt/perlbrew
instead of /opt/perl5/perlbrew
since there's no need for the extra level. The code snippets below assume you followed this recommendation.
Start from scratch, reinstalling any build of perl
you had.
Con: For each build, you'll also have to reinstall any modules that build had installed. This means you'll need to retest all your applications. This is time consuming, and not without risk.
Move the perlbrew
directory, but attempt to fix the installations.
Move the installation as follows:
mv ~/perl5/perlbrew /opt/
# Adjust file ownership and permissions as desired.
Then, edit the paths in each of the files printed by the following:
for q in /opt/perlbrew/perls/* ; do
"$q/bin/perl" -le'
use Config;
require "Config_heavy.pl";
print $INC{"Config.pm"};
print $INC{"Config_heavy.pl"};
'
done
You'll also need to edit the shebang (#!
) line of many scripts.
Con: Lots of work (though not nearly as much as the first option), fragile, and not guaranteed to work.
Create future builds in /opt/perlbrew
, but keep existing builds where they are.
After installing perlbrew
in /opt/perlbrew
, run the following:
cd /opt/perlbrew/perls
for q in ~/perl5/perlbrew/perls/* ; do
ln -s "$q"
done
Pro: Super simple and quick. Over time, you can phase out your ~/perl5/perlbrew
(by deleting unneeded builds, by replacing them as per option 1, or by moving them as per option 2).
Con: Everyone that should have access to /opt/perlbrew
also needs access to your ~/perl5/perlbrew
.
Don't change PERLBREW_ROOT
. Simply make /opt/perlbrew
a symlink.
ln -s ~/perl5/perlbrew /opt/perlbrew
Pro: Super simple and quick.
Con: Everyone that should have access to /opt/perlbrew
also needs access to your ~/perl5/perlbrew
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With