Skip to content

Fix permission issues when xcoll is installed in a read-only directory#211

Open
ekatralis wants to merge 1 commit into
xsuite:mainfrom
ekatralis:main
Open

Fix permission issues when xcoll is installed in a read-only directory#211
ekatralis wants to merge 1 commit into
xsuite:mainfrom
ekatralis:main

Conversation

@ekatralis

Copy link
Copy Markdown

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 /tmp as a last resort.

@freddieknets

Copy link
Copy Markdown
Collaborator

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, import xcoll fails (and hence the folders cannot be defined manually anymore)?

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 from platformdirs import user_config_dir, user_data_dir to let the OS provide the default paths. Ideally both should be possible.

I’ll have a look when I’m back from holiday (next week).

@ekatralis

ekatralis commented Jul 17, 2026

Copy link
Copy Markdown
Author

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 platformdirs on a linux installation also defaults to different subfolders inside the home directory:

>>> 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants