A shared perlbrew root for multiple users
作者:gugod 發佈於:Perhaps the biggest advantage of using perlbrew 0.15, is the possibility to share one perlbrew root among multiple users, assuming everyone uses bash (or zsh, which is compatible to bash.)
Let's assume the following scenario:
- The global perlbrew locates at /opt/perlbrew
- an user named
perlbrew
has write permission, and can install new perls and modules - all other users has read-only access
First of all, the perlbrew user should set PERLBREW_ROOT before installing perlbrew
:
export PERLBREW_ROOT=/opt/perlbrew
curl -L http://xrl.us/perlbrewinstall | bash
/opt/perlbrew/bin/perlbrew init
The perlbrew
executable is then installed as /opt/perlbrew/bin/perlbrew
. The init
command is required at this moment but it has be working to be automatically invoked when necessary. After this, everyone else in the system can simply add these two lines to their ~/.bashrc
to use perlbrew:
export PERLBREW_ROOT=/opt/perlbrew
source /opt/perlbrew/etc/bashrc
Each user now has a personal init file at ~/.perlbrew/init
, which is auto-generated to store the result of perlbrew switch
. Not using symlink anymore so there is no permission problem in the way. As long as users have read and exec permissions to some PERLBREW_ROOT
, they can invoke perlbrew exec
, perlbrew use
and perlbrew switch
just fine. /opt/perlbrew
can simply be managed by the root
user, no big deal. If you do not mind, you can share your $HOME/perl5/perlbrew
with others too.
This seems to be a pretty handy outcome of ditching the symlink approach. It might not be needed by many people. However when someone needs it, I hope it will be simple enough for them to do what they want.