I am at the moment starting some fresh fedora install and I am doing just that with the additional twist that I want perlbrew-managed perls to be installed by superuser(=root) so that all users can use them without each installing their own. Additionally I want root to install a good deal of common modules (e.g. LWP) for all users. After that, if users need to install obscure modules in their own private/home dirs, it is up to them. Or they ask superuser to install it for everybody in public dir.
I have found that this setup entails some danger.
Because I do not want root to have in their login/startup script all those perlbrew-related variables. Perhaps that's a purist view but I opted for creating a script for root to use whenever is going to need to do perlbrew-housekeeping and not having that same commands in root's .bashrc. Something like:
#!/bin/sh
# this is bin/use-perlbrew.sh (not part of ~/.bashrc)
export PERLBREW_ROOT=/opt/perlbrew
export PERLBREW_HOME=${HOME}/.perlbrew
source ${PERLBREW_ROOT}/etc/bashrc
CMD="perlbrew use perl-5.30.0"
echo "$0 : executing: ${CMD}"
eval ${CMD}
if [ $? -ne 0 ]; then echo "$0 : command has failed ${CMD}"; exit 1; f
+i
So, on login, root uses system perl and does not know about any perlbrew stuff. If root has to install perlbrew-wise modules then runs above script first (EDIT: via source ~/bin/use-perlbrew.sh). I find this cleaner than staffing root's .bashrc with tom, dick and harry.
I am aware that perlbrew can manage the system perl as well with just a symlink - no need of re-installing it (thanks to https://stackoverflow.com/questions/25188575/switching-to-the-system-perl-using-perlbrew). So one can suggest adding the perlbrew variables+source in root's .bashrc and immediately after that add perlbrew use system.
I suspect my dislike of that is cargo-culting. Anyone knows better? (I think I will SOPW this)
45 min EDIT: gaining root access via plain su inherits all env vars from current shell. Which includes all the perlbrew variables the calling user had. su --login stops that and is the proper way to gain root access if not doing it from the login screen. |