Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"crontab -e" backup file creation causes error if ~/.cache does not exist #173

Open
hannob opened this issue Jan 19, 2024 · 9 comments
Open

Comments

@hannob
Copy link
Contributor

hannob commented Jan 19, 2024

When using crontab -e and changing the crontab, I get this error:

/home/[username]/.cache/crontab: mkdir: No such file or directory

It seems recent cronie versions have introduced a feature to create backup files that are saved in ~/.cache/crontab. But it does not check that the ~/.cache directory exists.

@t8m
Copy link
Member

t8m commented Jan 19, 2024

I do not think I should create the .cache dir if it does not exist.

This message is just a warning and a backup won't be created but otherwise things should work.

There are basically three options:

  1. Silence the message if .cache is not present
  2. Make the message more comprehensive such as "No .cache directory in $HOME, backups won't be created."
  3. Create the crontab directory directly in home (probably with a different name such as .crontab-backups instead).

Which one is preferable?

@t8m
Copy link
Member

t8m commented Jan 19, 2024

My preference is either 2 or 3.

@hannob
Copy link
Contributor Author

hannob commented Jan 19, 2024

Creating ".cache" when it does not exist is what applications usually do, and what the spec says ("If, when attempting to write a file, the destination directory is non-existant an attempt should be made to create it with permission 0700. " https://specifications.freedesktop.org/basedir-spec/basedir-spec-0.8.html ).
Though I am wondering a bit if .cache is the correct place for a backup file anyway.

@hartwork
Copy link
Contributor

Though I am wondering a bit if .cache is the correct place for a backup file anyway.

Maybe XDG_DATA_HOME (default ${HOME}/.local/share) rather than XDG_CACHE_HOME.

PS: /var/lib/<editor> in FHS 3.0 seems related content-wise (but /var is probably no option here due to permissions).

@t8m
Copy link
Member

t8m commented Jan 23, 2024

I'd prefer keeping it at .cache / XDG_CACHE_HOME.

IMO an old backup file is something that does not have to be persistent. It is more like Oh I realized I made a mistake, can I revert?

@hartwork
Copy link
Contributor

@t8m I would like to highlight that a cache is substituting runtime by storage and it holds content that can be re-computed without loss at any time if deleted. If the content of a cache does not fit that model, it's probably not a cache. A backup is very different from that in that it holds content that has no guarantee that it can be recomputed in fact its mere cause of existence is to protect against that very cause. So in some sense a cache directory could hardly be further from a semantic match to storing backup files, or am I'm missing something?

@t8m
Copy link
Member

t8m commented Jan 24, 2024

That is one definition of cache which is a very strict one. In my opinion these backups are not meant to be permanent and I do not think there is a better place for such kind of "temporarily useful files" than .cache.

@hartwork
Copy link
Contributor

That is one definition of cache which is a very strict one.

@t8m what would be your definition of cache?

In my opinion these backups are not meant to be permanent

How is permanent or not important to this discussion? Please help me see it.

and I do not think there is a better place for such kind of "temporarily useful files" than .cache.

Why would XDG_DATA_HOME not be a fit or worse than XDG_CACHE_HOME for (temporary or not) backup files? I don't see why a cache folder would even be on the list of candidates for backup files. I already explained in detail why at #173 (comment) .

@t8m
Copy link
Member

t8m commented Jan 24, 2024

XDG_DATA_HOME is for permanent storage so it is definitely not the place I would like to use.

From the specs linked above: $XDG_CACHE_HOME defines the base directory relative to which user-specific non-essential data files should be stored. That sounds like a good fit for temporary backup files.

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

No branches or pull requests

3 participants