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
Allow string keys with gemrc #7543
Conversation
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.
Great idea, I always found this very confusing.
lib/rubygems/config_file.rb
Outdated
@disable_default_gem_server = @hash[:disable_default_gem_server] if @hash.key? :disable_default_gem_server | ||
@sources = @hash[:sources] if @hash.key? :sources | ||
@update_sources = @hash[:update_sources] if @hash.key? :update_sources | ||
# concurrent_downloads |
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.
Is the above comment intentional?
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.
Yes. I'm not sure why concurrent_download
is not handled this place. We should fix that for Gem.configuration.concurrent_downloads
.
But It's not this PR scope.
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.
So basically this comment is acting as a TODO note? If that's the case, I'd make that a bit more clear like TODO: Review why concurrent_downloads is not handled here
.
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.
I see. I did update that.
lib/rubygems/config_file.rb
Outdated
@@ -210,22 +210,32 @@ def initialize(args) | |||
@hash = @hash.merge environment_config | |||
end | |||
|
|||
@hash.transform_keys! do |k| | |||
if %w[backtrace bulk_threshold verbose update_sources cert_expiration_length_days | |||
install_extension_in_lib ipv4_fallback_enabled].include?(k) |
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.
How did you choose the list of configuration keys? I see there are a few more than this.
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.
Make sense. It's not strong reason.
I update that to deny list.
lib/rubygems/config_file.rb
Outdated
@@ -210,22 +210,32 @@ def initialize(args) | |||
@hash = @hash.merge environment_config | |||
end | |||
|
|||
@hash.transform_keys! do |k| | |||
# These keys didn't work as symbols | |||
if %w[gem install gemhome gempath].include?(k) |
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.
From the comment in lines 15-16 in this file:
gemrc is a YAML file that uses strings to match gem command arguments and
symbols to match RubyGems options.
My understanding is that right now, confusingly, you can specify any command name (or gem
for all commands), and that's specified as string. For RubyGems options, they are specified as keys.
So, I think we should:
- Include all commands here, not just
install
, otherwise configurations for other commands are going to be symbolized and possible break? - Remove or reword the comment above to no longer document this inconsistency.
Makes sense?
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.
I changed my proposal. I only convert Gem::ConfigFile
accessors. I don't want to work this simple issue to Gem.configuration
entirely.
Allow string keys with gemrc (cherry picked from commit bdb1468)
What was the end-user or developer problem that led to this PR?
I sometimes confused why it's not working correctly with the following
gemrc
.The correct case is
:verbose:
for that key. It's not useful for users.What is your fix for the problem, implemented in this PR?
I convert them to symbol keys if specified at gemrc.
Make sure the following tasks are checked