ruby-install icon indicating copy to clipboard operation
ruby-install copied to clipboard

Somehow support XDG

Open wilmoore opened this issue 9 years ago • 9 comments

My initial thinking is that if $XDG_DATA_HOME is set rubies would be installed into $XDG_DATA_HOME/rubies and if not set, they would be installed to ~/.local/share/rubies.

It would also be great if instead of ~/src/* sources were put into $XDG_CACHE_HOME/ruby/* if that variable is set or if not set ~/.cache/ruby/*.

In other words, try to avoid unnecessarily adding to the clutter of the $HOME directory.

XDG Base Directory Specification

wilmoore avatar Aug 08 '14 07:08 wilmoore

Storing rubies in ~/.local/share/rubies/ might be acceptable. ~/.rubies/ was choosen since it was the defacto directory that people were already using in the wild. We would have to support both dirs for a while, until people transitioned to ~/.local/share/.

One argument for ~/src/ is it does not hide the downloaded/uncompressed source. Users might forget that ruby-install downloads/uncompresses into ~/.cache/ruby-install/ and allow it to slowly bloat up thier /home partition.

postmodern avatar Aug 08 '14 23:08 postmodern

One argument for ~/src/ is it does not hide the downloaded/uncompressed source. Users might forget that ruby-install downloads/uncompresses into ~/.cache/ruby-install/ and allow it to slowly bloat up thier /home partition.

I can get behind that argument. I think a nice middle-ground then would be to keep the default as-is but allow it to be configurable. The user can then choose to use their already defined $XDG_CACHE_HOME directory to build the final path string if they wish.

wilmoore avatar Aug 09 '14 02:08 wilmoore

Slowly getting there! ruby-install 0.6.0 downloads versions/checksums into ~/.cache/ruby-install. Eventually will move the downloaded files into there. Might have to add a --clean-cache option to avoid files building up.

postmodern avatar Dec 28 '15 00:12 postmodern

I guess chruby also needs to look at both ~/.local/share/rubies and ~/.rubies?

FranklinYu avatar Jul 18 '18 18:07 FranklinYu

I guess chruby also needs to look at both ~/.local/share/rubies and ~/.rubies?

This is already part of https://github.com/postmodern/chruby/issues/405.

If/when chruby 1.0.0 is released, it may even default to ~/.local/share/rubies instead of ~/.rubies, see https://github.com/postmodern/chruby/commit/97e83c7e95a4d2b7451c1cd73b8b42cf92ef0b1e (docs) and https://github.com/postmodern/chruby/commit/0745073a1d54ceae4ec1267674836014cc05dbe6 (code).

guillaume-d avatar Aug 09 '22 12:08 guillaume-d

I'm starting to have second thoughts on ~/.local/share/rubies, since most macOS users do not use or are not used to XDG directories. This could create friction with macOS users.

postmodern avatar Aug 09 '22 19:08 postmodern

Lots of ideas and good arguments here: https://stackoverflow.com/questions/3373948/equivalents-of-xdg-config-home-and-xdg-data-home-on-mac-os-x

My 2 cents on where to install rubies after reading that (and Apple's docs about Library/ linked from there):

  1. if $XDG_DATA_HOME is defined: $XDG_DATA_HOME/rubies
  2. else if on macOS: default to ~/Library/rubies or ~/Library/Application Support/rubies
  3. [maybe add missing Windows case I do not care much about here]
  4. else default to ~/.local/share/rubies

Honestly I would not mind any default as long as $XDG_DATA_HOME gets honored. If you really want to make the rubies directory more discoverable by macOS users that are unware of the XDG base dir spec and also do not read documentation, I guess ~/.rubies or even ~/rubies (cross.platform, non-Unix users should not have to know about dotfiles either after all) is better really, but please only as a fallback then.

guillaume-d avatar Aug 12 '22 09:08 guillaume-d

most macOS users do not use or are not used to XDG directories

Is there a specific “scenario of frustration” in your mind, if we default to the XDG directories? In other words, when would users find it confusing?

FranklinYu avatar Aug 18 '22 08:08 FranklinYu

Is there a specific “scenario of frustration” in your mind, if we default to the XDG directories? In other words, when would users find it confusing?

More concerned about surprising users with a sudden switch to XDG directories, when most macOS users are not familiar with XDG directories since they were created by FreeDesktop.org specifically for Linux Desktop Environments; although more Linux/*nix software has become available on macOS thanks to homebrew and thus exposed more macOS to the concept of XDG directories.

What I will likely have to do is slowly introduce XDG support in both ruby-install and chruby. At first optionally supporting/honoring XDG directories if they exist. Then eventually defaulting to using XDG directories, but still have chruby recognize rubies installed in ~/.rubies/. Then in a 1.0.0 release, drop support for ~/.rubies/ and ~/src/ entirely in favor of XDG directories.

postmodern avatar Aug 18 '22 10:08 postmodern