Support XDG_* - #2174
Conversation
|
@deivid-rodriguez @aycabta Can you review this branch? I changed rubygems, bundler, rdoc, irb for XDG. I'm going to separate them for the upstream repositories after merging this. |
|
Ok, I'll have a look ASAP! |
aycabta
left a comment
There was a problem hiding this comment.
It's a good patch to merge to RDoc and IRB. I'll make another patch to Reline later.
deivid-rodriguez
left a comment
There was a problem hiding this comment.
The PR in general looks great to me. I only added a few minor comments. I think the backwards compatibility mechanism you used (optin if no prior config is there) should be fine 👍.
|
What's the motivation to use these XDG_* variables? Is there a request for it? |
|
|
|
@eregon from my experience it is not common to set those manually, but those are set in your environment (Linux/GNOME on my system) on its own to unify config,cache,data application files location. |
| credentials = File.join Gem.user_home, '.gem', 'credentials' | ||
| if File.exist? credentials | ||
| credentials | ||
| else | ||
| File.join Gem.data_home, "gem", "credentials" | ||
| end |
There was a problem hiding this comment.
This pattern of checking file existence appears to occur several times. Would it be helpful to encapsulate it in a utility method?
def find_home_file(filename)
path = File.join Gem.user_home, ".gem", filename
if File.exist? path
path
else
File.join Gem.data_home, "gem", filename
end
end|
@eregon The modern toolchains supported XDG Base Directory. See https://wiki.archlinux.org/index.php/XDG_Base_Directory |
|
@hsbt hello, are there any news on this? Is there any plan to move this forward? If needed I can help (for exmaple move rubygems part to rubygems repo as a PR). Ping me if that would be helpful. |
|
@simi Thanks for your comments. I'm going to merge about RubyGems, RDoc and IRB supports in this branch in few days. After that, I will backport to the upstream of them. Can you try it and improve them? Thanks. |
| # I have HOME, USERPROFILE and HOMEDRIVE + HOMEPATH. Ruby seems | ||
| # to be depending on HOME in those code samples. I propose that | ||
| # it should fallback to USERPROFILE and HOMEDRIVE + HOMEPATH (at | ||
| # least on Win32). |
There was a problem hiding this comment.
This comment is much outdated, for 1.8 era.
| Dir.chdir @tempdir | ||
|
|
||
| ENV['HOME'] = @userhome | ||
| FileUtils.mkdir_p File.join(@userhome, ".gem") |
There was a problem hiding this comment.
Why isn't this path reused bellow?
| FileUtils.mkdir_p File.dirname(temp_cred) | ||
| File.open temp_cred, 'w', 0600 do |fp| | ||
| fp.puts ':rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97' | ||
| end |
We should support XDG Base Directory Specification on the Ruby language.
I try to support the following environmental variables: