summaryrefslogtreecommitdiff
path: root/lib/rubygems/config_file.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/config_file.rb')
-rw-r--r--lib/rubygems/config_file.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb
index 54d8a9c152..393f947d77 100644
--- a/lib/rubygems/config_file.rb
+++ b/lib/rubygems/config_file.rb
@@ -261,7 +261,12 @@ if you believe they were disclosed to a third party.
# Location of RubyGems.org credentials
def credentials_path
- File.join Gem.user_home, '.gem', 'credentials'
+ credentials = File.join Gem.user_home, '.gem', 'credentials'
+ if File.exist? credentials
+ credentials
+ else
+ File.join Gem.data_home, "gem", "credentials"
+ end
end
def load_api_keys
@@ -444,6 +449,10 @@ if you believe they were disclosed to a third party.
# Writes out this config file, replacing its source.
def write
+ unless File.exist?(File.dirname(config_file_name))
+ FileUtils.mkdir_p File.dirname(config_file_name)
+ end
+
File.open config_file_name, 'w' do |io|
io.write to_yaml
end