From 253bfd7d09b78171f7c30444bade28aed458a067 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Thu, 22 Jan 2026 19:20:28 +0100 Subject: [PATCH] Check for folder in `sync_default_gems` (#15933) It was not clear to me that you have to do anything for this command to work. Previous versions (for example on the 3.4 branch) had this check but it got lost along the way. Without this when the folder doesn't exist, you get this error (after it deleted all the files): ``` $ ./tool/sync_default_gems.rb syntax_suggest Sync ruby/syntax_suggest ./tool/sync_default_gems.rb:464:in 'SyncDefaultGems.check_prerelease_version': undefined method 'version' for nil (NoMethodError) puts "#{gem}-#{spec.version} is not latest version of rubygems.org" if spec.version.to_s != latest_version ^^^^^^^^ from ./tool/sync_default_gems.rb:436:in 'SyncDefaultGems.sync_default_gems' from ./tool/sync_default_gems.rb:942:in '' from ./tool/sync_default_gems.rb:10:in '
' ``` Now you get ``` $ ./tool/sync_default_gems.rb syntax_suggest Sync ruby/syntax_suggest Expected '../ruby/syntax_suggest' (/home/earlopain/Documents/ruby/syntax_suggest) to be a directory, but it didn't exist. ``` This was changed in https://github.com/ruby/ruby/commit/b722631b481314023b9fa2f3fd16fa9ab0b4bf9c Since then, `sync_lib` is unused, delete it --- tool/sync_default_gems.rb | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index 14d7a3893d..477cc75546 100755 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -398,6 +398,10 @@ module SyncDefaultGems upstream = File.join("..", "..", config.upstream) + unless File.exist?(upstream) + abort %[Expected '#{upstream}' (#{File.expand_path("#{upstream}")}) to be a directory, but it didn't exist.] + end + config.mappings.each do |src, dst| rm_rf(dst) end @@ -798,26 +802,6 @@ module SyncDefaultGems return true end - def sync_lib(repo, upstream = nil) - unless upstream and File.directory?(upstream) or File.directory?(upstream = "../#{repo}") - abort %[Expected '#{upstream}' \(#{File.expand_path("#{upstream}")}\) to be a directory, but it wasn't.] - end - rm_rf(["lib/#{repo}.rb", "lib/#{repo}/*", "test/test_#{repo}.rb"]) - cp_r(Dir.glob("#{upstream}/lib/*"), "lib") - tests = if File.directory?("test/#{repo}") - "test/#{repo}" - else - "test/test_#{repo}.rb" - end - cp_r("#{upstream}/#{tests}", "test") if File.exist?("#{upstream}/#{tests}") - gemspec = if File.directory?("lib/#{repo}") - "lib/#{repo}/#{repo}.gemspec" - else - "lib/#{repo}.gemspec" - end - cp_r("#{upstream}/#{repo}.gemspec", "#{gemspec}") - end - def update_default_gems(gem, release: false) config = REPOSITORIES[gem] author, repository = config.upstream.split('/')