Fix permission issues when xcoll is installed in a read-only directory#211
Fix permission issues when xcoll is installed in a read-only directory#211ekatralis wants to merge 1 commit into
Conversation
|
I’m not a fan of automatically writing to the home folder, and neither of using a temp folder as this will be problematic when using FLUKA or Geant4 (they would need recompilation at every run). The config and lib folders can in principle be defined manually, but I guess if the folder is not writeable, I see two solutions, either to set the config and lib folders with a global environment variable (as for the prebuilt kernels in xsuite), or use I’ll have a look when I’m back from holiday (next week). |
|
I don't see why not to use the home directory for this. A . folder used to store config files or persistent files for an application is generally standard practice. It is also done by cupy/apptainer/vscode etc. Regardless, using >>> from platformdirs import user_config_dir, user_data_dir
>>> user_config_dir('xcoll')
'/home/evangeloskatralis/.config/xcoll'
>>> user_data_dir('xcoll')
'/home/evangeloskatralis/.local/share/xcoll'>>> from platformdirs import user_config_dir, user_data_dir
>>> user_config_dir('xcoll')
'/afs/cern.ch/user/e/ekatrali/.config/xcoll'
>>> user_data_dir('xcoll')
'/afs/cern.ch/user/e/ekatrali/.local/share/xcoll'I added the temporary file as a last resort, that branch should never really be reached under normal circumstances, but in this case we could throw a warning that there should be at least one writeable persistent directory for fluka and geant4. The environment variable could be a good idea to point the files to a desired directory, I agree. How are these config files handled when submitting jobs on htcondor? I assume that the paths differ in this case unless you keep everything on AFS (?). We can also discuss next week once you are back. |
Description
Xcoll creates config files inside the package directory. This can prove problematic if the packages is installed in a read-only file system (such as a container). This PR fixes this by checking whether the package directory is writeable. If it is not, it checks whether the home directory is available and writeable and selects that instead, falling back to
/tmpas a last resort.