New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support XDG_* #2174
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! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good patch to merge to RDoc and IRB. I'll make another patch to Reline later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is much outdated, for 1.8 era.
@@ -363,6 +363,14 @@ def setup | |||
Dir.chdir @tempdir | |||
|
|||
ENV['HOME'] = @userhome | |||
FileUtils.mkdir_p File.join(@userhome, ".gem") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't this path reused bellow?
lib/rubygems/test_case.rb
Outdated
FileUtils.mkdir_p File.dirname(temp_cred) | ||
File.open temp_cred, 'w', 0600 do |fp| | ||
fp.puts ':rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97' | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File.write
.
We should support XDG Base Directory Specification on the Ruby language.
I try to support the following environmental variables: