summaryrefslogtreecommitdiff
path: root/lib/rubygems/config_file.rb
diff options
context:
space:
mode:
authorJosef Šimánek <josef.simanek@gmail.com>2022-09-11 05:40:55 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2022-11-11 17:24:08 +0900
commitc7d043065c058f20ce30c61bb3ce127cb15cc0a8 (patch)
treedc36ca3f11e09451564500fa241fe3fdc521fde7 /lib/rubygems/config_file.rb
parentceeefb5870c144ddc069b2c9b8a19dbd4947a947 (diff)
[rubygems/rubygems] Add 'call for update' to RubyGems install command.
https://github.com/rubygems/rubygems/commit/05811f8248
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6715
Diffstat (limited to 'lib/rubygems/config_file.rb')
-rw-r--r--lib/rubygems/config_file.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb
index c53e209ae8..b18f4115cc 100644
--- a/lib/rubygems/config_file.rb
+++ b/lib/rubygems/config_file.rb
@@ -371,6 +371,18 @@ if you believe they were disclosed to a third party.
@backtrace || $DEBUG
end
+ # Check config file is writable. Creates empty file if not present to ensure we can write to it.
+ def config_file_writable?
+ if File.exist?(config_file_name)
+ File.writable?(config_file_name)
+ else
+ require "fileutils"
+ FileUtils.mkdir_p File.dirname(config_file_name)
+ File.open(config_file_name, "w") {}
+ true
+ end
+ end
+
# The name of the configuration file.
def config_file_name
@config_file_name || Gem.config_file