[ANN] BaseDirs.jl (was XDG)

After much indecision regarding the package name, BaseDirs is finally registered! :partying_face:

See the Pre-ANN/RFC thread for a recap on what the package is, but the TLDR; is it provides a cross-platform way of finding the appropriate place to look for/put files, because .julia is not a panacea.

This is a very small and lightweight package (with zero dependencies), using Julia 1.9-rc1 it takes ~25ms to load on my machine.

If you work on a package that asks any questions like “where should I put some cache files?”, “where can I find system fonts?”, “what’s a good place to save a document?” or similar, I’d recommend giving this package a look.

For more info, see the (somewhat detailed) docs: https://tecosaur.github.io/BaseDirs.jl


To finish off, here’s some example usage of the package:

julia> using BaseDirs

julia> BaseDirs.CONFIG_HOME[]
"/home/tec/.config"

julia> BaseDirs.User.config()
"/home/tec/.config"

julia> BaseDirs.User.config("sub", "dir/")
"/home/tec/.config/sub/dir/"

julia> BaseDirs.User.config(BaseDirs.Project("mything"), "config.conf", create=true)
"/home/tec/.config/mything/config.conf"
8 Likes

See GitHub - JuliaPackaging/Scratch.jl: Scratch spaces for all your persistent mutable data needs that features automatic garbage collection and optional versioning.

2 Likes

From a glance, since Scratch.jl seems to want to make interacting with cache files easier, I’d suggest that Scratch.jl itself may want to consider using BaseDirs to put the cache files in the platform-appropriate location.

1 Like