-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Store settings and packages in XDG directories instead of ~/.julia #4630
Comments
This is a nice and thorough proposal. |
Yes, this is a very well-presented proposal. However, we're not going to do this. We only just got |
Thanks for the kind words. ;-) I understand that changing the path to the config directory is not a nice task. That's why it took ten years and all programs haven't moved yet. But what I'm proposing merely amounts to changing the path from ~/.julia to ~/.config/julia. On 90% of systems it will be that way; only a few UNIX hackers will change the path to XDG_CONFIG_HOME, and they know what they are doing. There's no issue of the standard "working" or not: either the variable is defined, and you use it, or it's not, and you use your default path; in both cases you end up with the same result most of the time: ~/.config. This is my definition of "putting a bunch of files in a directory in the user's home directory". So I don't think this introduces a real inconsistency between OSes. BTW, it's false that FreeBSD does not support this: see Julia is still young, so it's not too late to switch. Big and popular cross-platform applications have made or are making the change: Chromium [1], Firefox (although not without debate [2]), VLC[3], LibreOffice, GIMP [4]. Disclaimer: though I'm member of the GNOME Foundation, I have no shares in Freedesktop.org. :-) 1: https://chromiumcodereview.appspot.com/12386077/ |
Having read through the spec, I'm not sold on this at all. I've got many issues with it.
Given all these issues and the fact that this causes a fairly major coding headache and fractures the IMO priceless uniformity of our cross-platform behavior, I'm sticking with my original gut reaction, which is to say no. |
I realize you mentioned that git "conforms" although it isn't a desktop program. Except that it doesn't really conform – git will look in the XDG locations if they exist, but if it needs to create a config file, it still creates |
It is ok for Julia to not follow XDG, however it is a nice thing to allow users to change |
like |
Quoting Fredrik in #37503 (comment):
|
I was kind of harsh in this issue before, but I still think that consistently putting all Julia-related stuff in The "spec" is terribly UNIX-specific and only makes sense on multiuser UNIX systems, which are no longer the common case: these days Linux and macOS dev laptops are the norm and the vast majority of servers are virtualized/containerized single-user systems. This spec really only makes sense on multiuser UNIX systems at research institutions. For the vast majority of users, the complexity of scattering everything around directories that aren't next to each other doesn't gain you anything since those directories are on the same file system on your computer's one and only hard disk. All it does it make it harder to see what's going on and add unnecessary complexity to Julia's Pkg and code-loading logic that works with those directories (which is already too complex). For those users that do actually work on a multi-user UNIX system where it makes sense to put config, cache and runtime data on different filesystems, it would be simple to create symlinks for the fixed set of subdirectories stored under
I'm not entirely sure how to map these onto XDG locations, which I feel is due to lack of clarity of the "spec" since I do understand what these directories are for but the spec doesn't really give clear criteria for what should go where, it just lists a bunch of technical properties of locations by which you're apparently supposed to infer, together with suggestive names, where to put things? I feel like people who want to use the spec can figure this out. For people who work on a single-user system where all the XDG directories are on the same file system but think that it's distasteful for Julia to clutter up their home directory with it's one |
Indeed it is nice that we can set a custom path for julia files. Going a bit further would help: currently users can't separate their configuration from the generated like registry clones. For users to be able to apply the spec to their own systems, it would be helpful if the |
|
It's unlikely that this will be worked on further in Julia itself. A third-party open source tool sounds like the right answer. |
I missed an important post from @StefanKarpinski in the other thread #10016 (comment):
So it seems it's on those of us who are interested in XDG to write the code but that @StefanKarpinski wouldn't be opposed to it. |
If someone wants to work on this, it's fine, but there are questions that needs answers. So far the "proposal" here is "Julia should follow the XDG spec". Ok, suppose we were to do that. What, concretely, does that mean? First and foremost, how do each of the directories I listed in #4630 (comment) map to XDG locations? Someone who has an interest in this needs to spend some time with the XDG spec and classify each of these and how they should relate to all the XDG environment variables. There are a lot of them: The next step would be to evaluate whether it makes sense to put this logic into Base and Pkg or not. My guess is that it is not worth the significant added complexity to both Base and Pkg, but if someone can refactor the Base and Pkg code so that it abstract over the XDG stuff cleanly, then a case could be made for it. An alternative is to have a utility package that goes through all the paths above and makes sure that |
I'd say, I don't think any of the directories belong in RUNTIME. config goes in CONFIG. Otherwise decide between DATA and CACHE based on the answer to "can the file can be created from scratch with no observable difference in behavior other than the waiting time to repopulate the cache?". As a first pass, how about:
Sources:
|
That's a good start. I would put |
I have reopened the issue as there's active interest in working on it apparently. |
I've been following this issue for some time, and I'm under the impression that beyond "some other applications follow the spec" the arguments for doing so, and why Julia should care, have not been spelled out very explicitly. Thus, I'd like to explain why this is important to me. For context, I'm only a very light user of Julia, but still
and I suspect that this could grow significantly when using more packages. I don't care very much about the aesthetics of separating things into
In both cases, there's an easy solution if cached data is centralized in Of course, this issue is by no means a problem unique to Julia, many (cross-platform) applications have similar behaviour. As a side note, I think appealing to the "non-desktopness of Julia" is missing the point: Julia is used on Linux desktop systems. I do agree that the XDG spec is lacking, in particular that There is one more feature I'd like to propose, which might also be a stopgap solution to the request for honoring the XDG spec: There's another non-universally respected specification for tagging cache directories using a As I've mentioned, I'm not using Julia very much, so I'm not going to work on this myself. I'd like to thank anyone who does in advance! |
Another solution, more flexible but less automatic, is to support
|
Can't you do all of that with symlinks? |
Ok, I can't resist the urge to chime in here. There seems to be a fair bit of FUD spread about XDG, its relevance to Julia, and the Linux community's attitude towards it in this issue and #10016. For starters, I'd like to rehash the case for Julia not ignoring XDG.
Now, onto some of the FUD. FUD 1
The freedesktop spec is not for "desktop as in GUI" it is for desktop as in "the Linux desktop", i.e. a computer I will sit in front of and use, and the programs on it. The fact that "graphical" and "desktop" are separate is made clear on the https://www.freedesktop.org homepage where the first sentence mentions "graphical and desktop systems". Julia is a desktop program. Git has previously been mentioned as an example of an XDG-conforming non-graphical program, and there's a large collection of others: alsa, curl, gdb, gnuplot, htop, less, python's pip and poetry, wireshark, ... FUD 2
It's already been mentioned that this does work on all Linuxes and FreeBSD. This concept does also apply to Mac and Windows. See this table taken from https://github.com/OpenPeeDeeP/xdg
FUD 3
This sounded very dodgy to me, so I hopped onto a nearby Linux server and asked. The results: 11 👍 in favour of XDG, 0 👎 against, and some extra comments like "xdg pls, can't believe devs are even considering otherwise" and "the typical Linux user will install more than just Julia.". We can also gauge Linux + Julia users' thoughts by looking at the reactions to this issue and comments.
Sure, there's going to be some overlap, but if you tally these reactions you get 56 reactions in favour of XDG and 3 against. I think we can safely conclude that the Linux + Julia community overwhelmingly wants XDG compliance. FUD 4
For starters, all modern *nix systems (Linux, BSD, Mac) are multi-user. Furthermore, while XDG spec may be good for multi-user + research systems, it also makes a lot of sense for single-person desktop setups too. @wisp3rwind has raised some points, but I also think an experience of mine may serves as an illustrative counter-example. I run an automated backup system on my computer, as I've been burned too many times by data loss/accidental deletions. To keep the size of my backups manageable, I blacklist certain directories that I know aren't that important. Thanks to XDG, I am able to eliminate a lot of unnecessary wastage by blacklisting If only Julia didn't seem set on reminding us why the XDG spec was created in the first place... On symlinks
To an extent, yes. In fact, here's a little script that makes Julia respect the XDG spec (untested, but should work). echo 'export JULIA_DEPOT_PATH=${XDG_DATA_HOME:-$HOME/.local/share}/julia' >> ~/.{bash,zsh,fish}env
mkdir -p ${XDG_CONFIG_HOME:-$HOME/.config}/julia
mkdir -p ~/.julia/config
mv ~/.julia/{config,environments} ${XDG_CONFIG_HOME:-$HOME/.config}/julia
ln -s ${XDG_CONFIG_HOME:-$HOME/.config}/julia/* ${XDG_DATA_HOME:-$HOME/.local/share}/julia
mkdir -p ${XDG_DATA_HOME:-$HOME/.local/share}/julia
mv ~/.julia/{artifacts,dev,logs,packages} ${XDG_DATA_HOME:-$HOME/.local/share}/julia
ln -s ${XDG_DATA_HOME:-$HOME/.local/share}/julia/* ${XDG_DATA_HOME:-$HOME/.local/share}/julia
mkdir -p ${XDG_STATE_HOME:-$HOME/.local/state}/julia
mv ~/.julia/{logs} ${XDG_STATE_HOME:-$HOME/.local/state}/julia
ln -s ${XDG_STATE_HOME:-$HOME/.local/state}/julia/* ${XDG_STATE_HOME:-$HOME/.local/state}/julia
mkdir -p ${XDG_CACHE_HOME:-$HOME/.cache}/julia
mv ~/.julia/{clones,compiled,registries} ${XDG_CACHE_HOME:-$HOME/.cache}/julia
ln -s ${XDG_CACHE_HOME:-$HOME/.cache}/julia/* ${XDG_DATA_HOME:-$HOME/.local/share}/julia However, I think "Can't you do all of that with symlinks?" is actually asking the wrong question. Why should Linux users have to manually wrangle Julia into (mostly) doing what it should do by default? |
I think we've arrived at the point where someone just needs to do it. See #4630 (comment) and #4630 (comment) for the desired directory assignments. |
Yup. Long posts and upvotes need to be converted into pull requests. Regarding what I posted above:
I think a potential issue with this classification is if CACHE files can be automatically deleted because while these files are perfectly reproducible from upstream servers, if they're deleted, programs that use them will stop working. So depending on how systems interpret the meaning of CACHE, it might not be appropriate. |
I agree. I think that, potentially, the precompilation cache ( |
Also, interestingly, packages and artifacts actually aren't user-specific, they are immutable and can be safely shared between all users. But they are typically installed by Julia as the user so without sufficient permission to install somewhere shared. So user data is probably the right classification. The |
I agree with the idea, I suppose it will be welcome for anyone. For those who are trying to get rid of |
It's probably worth mentioning here that I've just put together a package to make working with the XDG directories easier, with support for cross-platform equivalents. https://github.com/tecosaur/XDG.jl You can find the rational behind the decisions made in the docs. Just from taking a quick look, it seems like there are a number of packages that are currently dealing with this incorrectly, such as FreeTypeAbstraction.jl on Windows and Linux, DataDeps.jl, then the various packages using ad-hoc cache, and the other packages beginning to clutter |
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:
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.
The text was updated successfully, but these errors were encountered: