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

[xdg] provide macOS known directories #10413

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AllanBlanchard
Copy link

Fix #10398

Add ?macos:bool argument to Xdg.create. When enabled, Xdg uses known macos directories, that is:

  • ~/Library/Caches for cache,
  • ~/Application Support otherwise.

Implication of each default:

  • false: preserves current behavior but inconsistent with ?win32 default behavior,
  • true: consistent with ?win32 default, but macOS users of packages that use Xdg will potentially lose their config.

- disabled by default, ?macos argument is used to enable it

Signed-off-by: Allan Blanchard <allan.blanchard0@gmail.com>
@AllanBlanchard AllanBlanchard marked this pull request as ready for review April 11, 2024 06:29
@AllanBlanchard
Copy link
Author

@rgrinberg I let you decide of the default, or even whether you want to introduce the feature or not.

environment variables, typically {!Sys.getenv_opt}. *)
val create : ?win32:bool -> env:(string -> string option) -> unit -> t
val create :
?win32:bool -> ?macos:bool ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's weird to allow passing ~win32:true and ~macos:true at the same. Could you add a separate function for macos instead?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I just realize that I didn't understand at all how the library is meant to be used 😅 . Now I get it, I'll change that. Thank you.

@AllanBlanchard AllanBlanchard marked this pull request as draft April 12, 2024 06:41
@Leonidas-from-XIV
Copy link
Collaborator

Leonidas-from-XIV commented Apr 12, 2024

While I understand the appeal of using the macOS standard directories and it might be sensible for Dune itself, it seems incorrect in the context of XDG specifically.

Quoting the specification:

$XDG_CACHE_HOME defines the base directory relative to which user-specific non-essential data files should be stored. If $XDG_CACHE_HOME is either not set or empty, a default equal to $HOME/.cache should be used.

Thus if we return $HOME/Library/Caches on unset $XDG_CACHE_HOME that would violate the specification.

@jonahbeckford
Copy link
Collaborator

I get @Leonidas-from-XIV 's concern, although I think the use of this library has been to map to the conventions on the operating systems. If not, you could not use the XDG library on Windows.

Maybe we could disambiguate: use a ~strict option if you need strict compliance of XDG? Of course, it would be highly inappropriate to do a strict reading of the spec on Windows, but at least if something really needs full XDG compliance they can get it.

I am really interested in the conventional macOS directories; it is 74 apps+variants in ~/Library/Application Support versus 19 in ~/.config on my machine ... and 3 of those 19 are (wrongly IMHO) influenced by the Xdg library.

@rgrinberg
Copy link
Member

"strict" I think is too vague and open to interpretation. I wouldn't mind constructors for Xdg.t that interpret the spec differently. In the end, all that matters for us is how dune interacts with the spec, and not what other users of the xdg library want their programs to do. So if it's useful for them to tweak the standard for their uses, I don't see a problem with it.

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.

Xdg support: directories used for macOS
4 participants