C++ file not found in ROOT 6

I’m going through the CERN beginner’s guide and I have created the slits.C file. When I load up root it says I am in the Rint: / directory but when I try to load the slits.C file it says

Error in TRint::ProcessLine: macro slits.C not found in path .:/snap/root-framework/232/usr/local/macros

I have tried creating this file pathway because it doesn’t exist when I follow it and then saving the slits.C file in there, but that isn’t working.

I also am unable to change my working directory using any of the following commands, (.cd, .cd /, .cd ~).

TIA

You can change the directory ROOT is operating in with gSystem->cd("/path/to/directory"), after which .!pwd or gSystem->pwd() should confirm the change. It’s likely easier though in the Bash prompt to use cd before root, since ROOT should start in the same directory that Bash is in when you open it. .!ls should list slits.C if you’re in the right working directory.

Modifying the paths under /snap isn’t generally allowed (the files there are all mounted read only and only exist in RAM and not on the actual disk) and in this case probably not needed, ROOT should be able to find your macro if it’s in the same working directory as your macro file.

You can also try run the macro from Bash, root /path/to/slits.C, and if you’re new to ROOT I’d recommend giving root --notebook a go which should open an interactive JupyROOT session in your browser, this deviates off of the tutorials slightly but provides a light IDE environment that might help you iterate on your work more quickly.