Sourcing root for all users

So, the common approach for sourcing ROOT seems to be just including

source /path/to/root/bin/thisroot.sh

in your ~/.bashrc

I was thinking that in order for it to work for all users, you could do the same in /etc/bash.bashrc (but that doesn’t seem to work). And that for it to work also when accessing the computer via SSH, you could do the same in /etc/environment. Neither of these options, however, seem to work for me, and I’m at my wits’ end.

How have/would you solve this? I want to set the machine up so that all users always can launch the “current” ROOT version (which would then be defined in e.g. /etc/bash.bashrc or /etc/environment).

I’m doing version installations under /opt; e.g. /opt/root-6.10.02, and then I thought I can just set up aliases for the different version (if I can only get this bit to work). I’m thinking that having users install different versions under /usr or /home will lead to several instances of the same version.

Edit: Apparently I didn’t read the full post, will go through it soon. I only got the shortened version when I tried to open the link on my mobile device.

That’s more or less what I say, too.
Just do NOT put any “default ROOT” settings in any standard “environment” files.
Every user should always be expected to source an appropriate “thisroot.[c]sh” for the ROOT version that [s]he wants to use.
Note: you can easily create shell aliases for them (and put them in any standard “environment” files) … something like:

alias root-53436='source /opt/ROOT/releases/root_v5.34.36/bin/thisroot.sh'
alias root-60902='source /opt/ROOT/releases/root_v6.09.02/bin/thisroot.sh'
alias root-61004='source /opt/ROOT/releases/root_v6.10.04/bin/thisroot.sh'
alias root-old="root-53436"
alias root-pro="root-60902"
alias root-new="root-61004"
alias root-dev="root-61004"
alias root-5="root-old"
alias root-6="root-new"

Actually, I myself do not put any “default ROOT” settings in any of my private “${HOME}/.profile”, “${HOME}/.bashrc” (and so on) files. I always call one of the above aliases in every [x]terminal in which I want to use ROOT.
BTW. My “original post” contains advices how to “configure” ROOT but they are quite old and suited for ROOT 5 and early versions of ROOT 6 (but not really for newer ROOT 6 versions).

1 Like

I am a big fan of using environment-modules. This permits the user a quick way to see what is available and switch in various version as they need:

$ module avail       
-------------------- /usr/local/Modules/3.2.10/modulefiles ---------------------
dot                       module-info               root/6.09.02
geant4/10.03.p01          modules                   root/6.10.00
geant4/10.03.p02(default) root/5.34.36              root/6.10.02(default)
macports                  root/6.08.06              use.own
$ module load root
$ module list
Currently Loaded Modulefiles:
  1) macports       2) root/6.10.02
$ module switch root/6.10.02 root/5.34.36
$ module list
Currently Loaded Modulefiles:
  1) macports       2) root/5.34.36
$ module unload root
$ module list
Currently Loaded Modulefiles:
  1) macports
$ module load root/6.10.00
$ module list
Currently Loaded Modulefiles:
  1) macports       2) root/6.10.00
1 Like

another possibility is to use direnv:

https://direnv.net/

it works on a per-directory basis.

e.g

$> mkdir -p foo/bin
$> cd foo
$> cat > .envrc
export FOO=`pwd`
export PATH=$FOO/bin:$PATH
^C

## do the following only once
$> direnv allow .
$> echo $FOO
/home/binet/foo

no need for special privileges (like installing environment-modules.)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.