Skip to content
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

Merged
merged 2 commits into from Apr 2, 2024
Merged

Allow string keys with gemrc #7543

merged 2 commits into from Apr 2, 2024

Conversation

hsbt
Copy link
Member

@hsbt hsbt commented Mar 29, 2024

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.

gem: "--no-document"
verbose: false

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

Copy link
Member

@deivid-rodriguez deivid-rodriguez left a 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.

@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
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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.

@@ -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)
Copy link
Member

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.

Copy link
Member Author

@hsbt hsbt Apr 1, 2024

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.

@@ -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)
Copy link
Member

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?

Copy link
Member Author

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.

@hsbt hsbt merged commit bdb1468 into master Apr 2, 2024
75 checks passed
@hsbt hsbt deleted the allow-string-keys branch April 2, 2024 07:08
deivid-rodriguez pushed a commit that referenced this pull request Apr 4, 2024
Allow string keys with gemrc

(cherry picked from commit bdb1468)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants