Error merge root files using hadd

Hi all,
I want to merge some root files under the folder(/data/yaokq/forward). I run the following code, but get errors.I’m obviously running in the “/data/yaokq/forward” folder, why does it show I don’t have permissions in the “/var/lib/snapd/void/” folder.

uer:/data/yaokq/forward$ hadd output.root a.root b.root
Error:
hadd Target file:output.root
hadd compression setting for all output:1
SysError in TFile::TFile: file /var/lib/snapd/void/output.root can not be opened Permission denied
Error in TFileMerger::OutputFile:cannot open the MERGER output file
hadd error opening target file(does output.root exist?)

Hi,

Welcome to the ROOT community!
This seems to be an issue of the way your system is configured and not a problem of ROOT.
However, let me ask a question based on the error message you pasted in the previous post: does the output.root file exist?

Best,
D

It seems that you installed ROOT through snap, so the “base” directory of snap is picked somehow, where you cannot write any output file (/var/lib/snapd/void/).

Try changing output.root with /home/youruser/output.root or /tmp/output.root, any directory where you can write. You maybe also need to add /data/yaokq/forward before a.root

Thanks! The output.root file dosen’t exist.But I think the target file will be generated automatically.

As ferhue suggested, try adding the full paths to all filenames (output and input). You should also check whether any snapd setting is somehow forcing the use of that folder (not a ROOT issue, so you need the proper forum, or google/etc, for that), or reinstall ROOT but not as snap; you can download a precompiled binary if your OS & distro is supported, or even compile your own if needed.

I installed ROOT through conda.I followed your suggestion and added the path address before the target and merged files. It seems to be right.As I remember it can be done without adding absolute path.