From c7d043065c058f20ce30c61bb3ce127cb15cc0a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20=C5=A0im=C3=A1nek?= Date: Sun, 11 Sep 2022 05:40:55 +0200 Subject: [rubygems/rubygems] Add 'call for update' to RubyGems install command. https://github.com/rubygems/rubygems/commit/05811f8248 --- lib/rubygems/config_file.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/rubygems/config_file.rb') 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 -- cgit v1.2.3