Installing ROOT on WSL2

Dear all, I am trying to install ROOT via a package manager Snap since it is a pre-requisite for GATE/Geant4. When I try to snap run root-framework, the following output shows:

2024/11/06 12:11:16.917855 cmd_run.go:1285: WARNING: cannot start document portal: dial unix /run/user/1000/bus: connect: no such file or directory
   ------------------------------------------------------------------
  | Welcome to ROOT 6.30/08                        https://root.cern |
  | (c) 1995-2024, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Jul 14 2024, 22:53:16                 |
  | From tags/v6-30-08@v6-30-08                                      |
  | With c++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0                   |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------

root [0] 

How can I continue and should I install ROOT in the same folder as my GATE directory?

ROOT Version: 6.30/08
Platform: WSL2 (Ubuntu 22.04.3 LTS)
Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

Thanks in advance!

Hello @JSWong, welcome to the ROOT Forum.

I’m not sure I fully understand your issue, but what you are seeing there is the ROOT command line tool prompt, so it seems that ROOT was successfully installed on the machine.
If you want to quit the command line tool you can just type .q and Enter.
If you don’t need to use ROOT directly, this should be enough; otherwise you probably want to setup the proper environment to use it via source /path/to/root_installation/bin/thisroot.sh.

Please let me know if you need anything else.

Yes, I thought the same too, that ROOT is installed since there is a command line prompt, but I could not continue with the installation of GATE with the error regarding ROOT:

CMake Error at CMakeLists.txt:130 (FIND_PACKAGE):
  By not providing "FindROOT.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "ROOT", but
  CMake did not find one.

  Could not find a package configuration file provided by "ROOT" with any of
  the following names:

    ROOTConfig.cmake
    root-config.cmake

  Add the installation prefix of "ROOT" to CMAKE_PREFIX_PATH or set
  "ROOT_DIR" to a directory containing one of the above files.  If "ROOT"
  provides a separate development package or SDK, be sure it has been
  installed.

Have you tried running cmake after sourcing thisroot.sh?

No. I only installed in with the command sudo snap install root-framework and I also could not find where it was installed since there was no directory created.

I am not familiar with Snap, so maybe a better way for installation is to download a pre-compiled binary distribution like stated on the installation website? (Sorry, I cannot post links yet)

Installing the binaries is certainly an option, otherwise I think Snap installs packages under /snap, so you can try looking there.
This command should give you the path of the script to source: find /snap -name thisroot.sh

Unfortunately the ROOT snap can’t really integrate with other packages, the sandboxing and potential ABI incompatibilities cause problems.

However, there’s already a Gate snap, which has ROOT built in. The ROOT in the Gate snap isn’t meant to be used directly, so you’d probably want both the ROOT snap and the Gate snap, but the Gate snap can run without ROOT installed separately.

(Similarly, the GATE snap already has Geant4)

sudo snap install gate

The Gate snap also has QT, so you should be able to open it as gate --qt or via the Windows start menu where it’ll be added as a start menu entry.

1 Like

Thanks, I found it.

I tried and I have successfully installed GATE, thanks a lot!

Hi again! The QT from Gate snap works, but since everything is protected in the snap environment, I could not edit the .mac files even if I ‘retry as Admin’, and run simulations. Moving and creating files and folders are not directly accessible as well. Is there any way to access and edit the files more easily?

1 Like

Ideally you should be copying them from those folders and modifying them in $HOME, however, technically yes.

You can’t edit the files because they’re mounted in memory from the squashfs archive that contains them; this is intentional since the package manager can very quickly do a checksum on a single file to detect bitrot or malicious tampering.

You can pretty trivially go into a developer mode that gets you what you want though, try:

snap download gate
unsquashfs gate*.snap
sudo snap remove gate --purge
sudo snap try squashfs-root

This downloads the the snap, extracts it into a normal folder, removes the original install, and then installs it using the squashfs-root directory you just created. (Consider moving/renaming this before you use snap try).

Since it’s now just a normal folder, you can edit the files inside it. When the snap runs, that folder appears as /snap/gate/current/, changes will be instant.

Just out of caution, when done like this, the executable name will be gate in lowercase, not Gate and gate covering both. If you want the uppercase version to match upstream (which might be important if you use any scripts or copy commands from the internet), you’d run sudo snap alias gate Gate and this should make it respond to both.

If that folder ends up missing or damaged to the point of repair, sudo snap remove gate --purge and extract and mount it again.