End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Gem::ConfigFile#set_api_key
set_api_key(host, api_key)
lib/rubygems/config_file.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.0.5/lib/rubygems/config_file.rb, line 317
def set_api_key(host, api_key)
check_credentials_permissions
config = load_file(credentials_path).merge(host => api_key)
dirname = File.dirname credentials_path
require 'fileutils'
FileUtils.mkdir_p(dirname)
Gem.load_yaml
permissions = 0600 & (~File.umask)
File.open(credentials_path, 'w', permissions) do |f|
f.write config.to_yaml
end
load_api_keys # reload
end
Set a specific host’s API key to api_key
See also
#rubygems_api_key=
#set_config_file_name
#rubygems_api_key
#unset_api_key!
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1