postmodern / ruby-install

Installs Ruby, JRuby, TruffleRuby, or mruby
MIT License
1.91k stars 255 forks source link

Somehow support XDG #156

Open wilmoore opened 10 years ago

wilmoore commented 10 years ago

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

postmodern commented 10 years ago

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.

wilmoore commented 10 years ago

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.

postmodern commented 8 years ago

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.

FranklinYu commented 6 years ago

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

guillaume-d commented 2 years ago

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).

postmodern commented 2 years ago

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.

guillaume-d commented 2 years ago

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.

FranklinYu commented 2 years ago

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?

postmodern commented 2 years ago

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.

todd-a-jacobs commented 1 month ago

My solution for XDG is to install things under appropriate XDG directories, and then symlink them to dot files or directories in $HOME for convenience. For example, symlinking .config/chruby/default-ruby to ~/.ruby-version follows XDG conventions (which are not universally loved) but still follow the principle of least surprise. Worth considering?