Specify location of user folders and files on Unix OS - if $HOME is not set

Problem: if $HOME is not set (for example if running a build under a limited 'service' account.

Solution: set $XDG_DATA_HOME to point to a suitable parent folder, where the user files can be found.


What is $XDG_DATA_HOME?

An environment variable to specify:

  • Where user-specific data files should be written (analogous to /usr/share).
  • Should default to $HOME/.local/share

References

- XDG Base Directory

- XDG Base Directory Specification


Comments