HenrikBengtsson / startup

:wrench: R package: startup - Friendly R Startup Configuration
https://henrikbengtsson.github.io/startup/
163 stars 5 forks source link

Use the XDG base directory specification #69

Closed klmr closed 2 years ago

klmr commented 5 years ago

This package currently creates not one but two (hidden) directories inside the user’s home directory. Many users find this undesirable, as it clutters a perfectly fine home directory (being hidden helps somewhat but not much).

To mitigate this, freedesktop.org has standardised a set of directories and environment variables to use for such situations in the XDG base directory specification. Simply put, all such directories should reside as (non-hidden) directories under ~/.config, unless overridden via environment variables.

This change can be made in a (mostly) backwards compatible manner by first searching the XDG paths and falling back to the current paths.

HenrikBengtsson commented 5 years ago

The current logic is that .Renviron.d/ and .Rprofile.d/ are sibling folders to the .Renviron and .Rprofile files. The current setup will work the same regardless where your .Rprofile lives, e.g. ./.Rprofile, ~/.Rprofile, /path/to/site/.Rprofile, ...

The decision would straightforward if R itself would use ~/.config/.Renviron and ~/.config/.Rprofile.

But, I hear you - I'll digest/mature/ferment this proposal slowly. It might be possible to introduce XDG as an option, e.g. startup::install(xdg = TRUE), and if successful maybe promote it to the default.

PS. On a side note, I've actually already prepared to use XDG for an internal cache in the upcoming version (https://github.com/HenrikBengtsson/startup/blob/develop/R/os_cache_path.R).

HenrikBengtsson commented 2 years ago

For XDG support, I'm thinking of using:

> file.path(tools::R_user_dir("startup", which = "config"), c("Renviron.d", "Rprofile.d"))
[1] "/home/alice/.config/R/startup/Renviron.d" "/home/alice/.config/R/startup/Rprofile.d"
HenrikBengtsson commented 2 years ago

I've added support for this to the next release (available in the develop branch).