Skip to content

Store settings and packages in XDG directories instead of ~/.julia #4630

@nalimilan

Description

@nalimilan

Over the last 10 years most Freedesktop environments (GNOME, KDE, XFCE...) and applications around them have moved to store configuration in the XDG config directory (by default ~/.config) instead of creating a hidden directory directly into the home folder. A well-known non-GUI application that does the same is git:
https://github.com/git/git/blob/master/Documentation/RelNotes/1.7.12.txt#L18-23

The Freedesktop specification is here:
http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

and a rationale for this specification can be found here:
https://wiki.gnome.org/GnomeGoals/XDGConfigFolders

I think Julia should follow it too. The idea is very simple, you just need to read an environment variable:

$XDG_CONFIG_HOME defines the base directory relative to which user specific configuration files should be stored. If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used.
http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

Thus, in case $XDG_CONFIG_HOME is not defined, settings would be stored in the default ~/.config/julia.

Packages should likely go to $XDG_DATA_HOME, which defaults to .local/share/ (the equivalent of /usr/share/). One rule of thumb is that configuration is more like text files with limited size and that do not change that much (some people even keep it under a VCS). OTOH $XDG_DATA_HOME is usually conceived as a place to store valuable user data, which needs backup, while packages can easily be downloaded again. After much reading and thinking I still don't know so this probably means it does not really matter.

So the changes would be pretty limited actually. In the documentation, it would be sensible to speak about ~/.config/julia instead of ~/.julia, without mentioning the environment variables trick (users who change the defaults will know).

One of the potential gains of following that XDG spec is that it also defines $XDG_CONFIG_DIRS and $XDG_DATA_DIRS, which could be used by administrators to provide a system-wide package library, and default settings for new users. Julia would read config from there, but only save user config and packages in the user home directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    won't changeIndicates that work won't continue on an issue or pull request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions