Skip to content

Document and test all available gemrc configuration keys#9568

Merged
hsbt merged 1 commit into
ruby:masterfrom
junaruga:wip/improve-rubygems-config-file
Jun 1, 2026
Merged

Document and test all available gemrc configuration keys#9568
hsbt merged 1 commit into
ruby:masterfrom
junaruga:wip/improve-rubygems-config-file

Conversation

@junaruga

Copy link
Copy Markdown
Member

What was the end-user or developer problem that led to this PR?

I noticed that some gemrc configuration keys were not documented in the current RubyGems ConfigFile document page.

What is your fix for the problem, implemented in this PR?

I documented the missing gemrc configuration keys, and added and updated tests for gemrc configuration use_psych and gemhome keys that didn't have the assertions.

The documented configuration key order aligns with the following part.

@backtrace = @hash[:backtrace] if @hash.key? :backtrace
@bulk_threshold = @hash[:bulk_threshold] if @hash.key? :bulk_threshold
@verbose = @hash[:verbose] if @hash.key? :verbose
@update_sources = @hash[:update_sources] if @hash.key? :update_sources
@concurrent_downloads = @hash[:concurrent_downloads] if @hash.key? :concurrent_downloads
@cert_expiration_length_days = @hash[:cert_expiration_length_days] if @hash.key? :cert_expiration_length_days
@install_extension_in_lib = @hash[:install_extension_in_lib] if @hash.key? :install_extension_in_lib
@ipv4_fallback_enabled = @hash[:ipv4_fallback_enabled] if @hash.key? :ipv4_fallback_enabled
@global_gem_cache = @hash[:global_gem_cache] if @hash.key? :global_gem_cache
@use_psych = @hash[:use_psych] if @hash.key? :use_psych
@home = @hash[:gemhome] if @hash.key? :gemhome
@path = @hash[:gempath] if @hash.key? :gempath
@sources = @hash[:sources] if @hash.key? :sources
@disable_default_gem_server = @hash[:disable_default_gem_server] if @hash.key? :disable_default_gem_server
@ssl_verify_mode = @hash[:ssl_verify_mode] if @hash.key? :ssl_verify_mode
@ssl_ca_cert = @hash[:ssl_ca_cert] if @hash.key? :ssl_ca_cert
@ssl_client_cert = @hash[:ssl_client_cert] if @hash.key? :ssl_client_cert

I fixed test_initialize_global_gem_cache_gemrc and
test_initialize_concurrent_downloads to test with symbolic keys, as global_gem_cache and use_psych keys are documented as a symbolic key.

I tested with the following Ruby in Fedora Linux 43.

$ which ruby
~/.local/ruby-4.1.0-debug-3ef48ef9c8-openssl-4.1.0-7194354488/bin/ruby

$ ruby -v
ruby 4.1.0dev (2026-05-19T11:31:50Z master 3ef48ef9c8) +PRISM [x86_64-linux]

I confirmed the updated document page by the following commands:

$ bin/rake docs:server
...
Serving documentation at: http://localhost:4000
Press Ctrl+C to stop.

$ firefox http://localhost:4000/Gem/ConfigFile.html

I tested the updated test file by the following command:

$ ruby -Ilib:test:bundler/lib test/rubygems/test_gem_config_file.rb
Loaded suite test/rubygems/test_gem_config_file
Started
..........................................
Finished in 0.169670163 seconds.
-----------------------------------------------------------------------------------------------------------------------------
42 tests, 199 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
-----------------------------------------------------------------------------------------------------------------------------
247.54 tests/s, 1172.86 assertions/s
Coverage report generated for rubygems to /home/jaruga/var/git/ruby/rubygems/coverage.
Line Coverage: 33.56% (1766 / 5263)

Make sure the following tasks are checked

@junaruga

Copy link
Copy Markdown
Member Author

I see RUBYGEMS_USE_PSYCH=true is set in the following CI case.

- ruby: { name: 4.0 (psych), value: 4.0.0 }
os: { name: Ubuntu, value: ubuntu-24.04 }
use_psych: true
- ruby: { name: no symlinks, value: 4.0.0 }
os: { name: Windows, value: windows-2025 }
symlink: off
env:
RUBYGEMS_USE_PSYCH: ${{ matrix.use_psych || 'false' }}

That caused at line 47 assertion to test use_psych default value fail, by the @cfg.use_psych being true in the case. I drop the use_psych default test.

 36   def test_initialize
 37     assert_equal @temp_conf, @cfg.config_file_name
 38
 39     assert_equal true, @cfg.backtrace
...
 46     assert_equal true, @cfg.install_extension_in_lib
 47     assert_equal false, @cfg.use_psych

https://github.com/ruby/rubygems/actions/runs/26521953541/job/78115180934?pr=9568#step:6:8

@junaruga junaruga force-pushed the wip/improve-rubygems-config-file branch from 593acca to f20a900 Compare May 27, 2026 16:01
Document missing gemrc configuration keys. The documented configuration key
order aligns with the following part.

https://github.com/ruby/rubygems/blob/287175d4ae57340e22c6f1d21da1489d7dac35c5/lib/rubygems/config_file.rb#L240-L257

Add and update tests for missing gemrc configuration use_psych and gemhome key
assertions.

Fix test_initialize_global_gem_cache_gemrc and
test_initialize_concurrent_downloads to test with symbolic keys,
as global_gem_cache and use_psych keys are documented as a symbolic key.
@junaruga junaruga force-pushed the wip/improve-rubygems-config-file branch from f20a900 to 8baf4d4 Compare May 27, 2026 16:20
end

def test_initialize_use_psych_env
orig_use_psych = ENV["RUBYGEMS_USE_PSYCH"]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered the environment where RUBYGEMS_USE_PSYCH=true is set, backing up the original value of the RUBYGEMS_USE_PSYCH. There is actually the case in the CI.

The test_initialize_ipv4_fallback_enabled_env and test_initialize_global_gem_cache_env also hav the same issue where these environment variables are set. But as I felt fixing these 2 tests were out of scope of this PR, I didn't fix the tests.

@junaruga

Copy link
Copy Markdown
Member Author

The motivation of this PR is that we may need new PQC-specific configuration keys for gemrc to implement PQC in RubyGems (#9542). This PR is a preparation for the possible situation.

@hsbt hsbt merged commit 4bafea5 into ruby:master Jun 1, 2026
93 checks passed
@junaruga junaruga deleted the wip/improve-rubygems-config-file branch June 1, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants