Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Gem::ConfigFile#unset_api_key!
unset_api_key!
lib/rubygems/config_file.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/config_file.rb, line 511
def unset_api_key!
store = active_credential_store
store_cleared =
if store.nil?
true
elsif store.available?
store.delete_all
else
# Failing here would make signout exit 1 on every platform without a
# native store, and plain success would claim a removal nobody made.
Gem::CredentialStore.warn_once "The credential store is enabled but unavailable, so any key it holds was left in place."
true
end
file_removed =
if File.exist?(credentials_path)
# POSIX deletes a read-only file whenever the directory is writable, so
# the marking has to be honored explicitly.
if File.writable?(credentials_path)
begin
File.delete(credentials_path)
true
rescue SystemCallError
false
end
else
false
end
else
false
end
[store_cleared, file_removed]
end
Remove the +~/.gem/credentials+ file to clear all the current sessions, and every RubyGems key from the credential store when the credential_store setting is on, including keys saved for other hosts with gem signin --host.
See also
#state_file_writable?
#warn_credential_store_fallback
#state_file_name
#warn_unremoved_credential
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0