Executing a macro from my external hard drive

Your problem looks similar to this one:

Which is not a ROOT problem, but apparently a general issue (feature?) with snaps, see for example

Since you are on Ubuntu, try instead using a precompiled version of ROOT (make sure it’s the one for Ubuntu 22.04!) instead of installing a snap package.