From c30d74b3e2522c081e083cc860646b7a43c5511f Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Fri, 10 Apr 2026 15:44:58 +0100 Subject: Ensure version from bundled_gems is used in tool/rdoc-srcdir (#16712) Use version from bundled_gems in tool/rdoc-srcdir Previously, `tool/rdoc-srcdir` used `Dir.glob(...).first` to find bundled gems like rdoc and tsort. This picks the first match alphabetically, which can select a stale older version when multiple versions coexist in `.bundle/gems/` (e.g. `rdoc-7.1.0` over `rdoc-7.2.0`). Fix by reading the declared version from `gems/bundled_gems` and constructing the exact path, ensuring the correct version is always loaded regardless of leftover directories. --- tool/rdoc-srcdir | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tool/rdoc-srcdir b/tool/rdoc-srcdir index ecc49b4b2c..67d024fc0b 100755 --- a/tool/rdoc-srcdir +++ b/tool/rdoc-srcdir @@ -1,7 +1,16 @@ #!ruby -W0 +srcdir = File.dirname(__dir__) +bundled_gems = File.join(srcdir, "gems/bundled_gems") +versions = {} +File.foreach(bundled_gems) do |line| + next if line.start_with?("#") || line.strip.empty? + name, version, = line.split + versions[name] = version +end + %w[tsort rdoc].each do |lib| - path = Dir.glob("#{File.dirname(__dir__)}/.bundle/gems/#{lib}-*").first + path = File.join(srcdir, ".bundle/gems/#{lib}-#{versions[lib]}") $LOAD_PATH.unshift("#{path}/lib") end require 'rdoc/rdoc' -- cgit v1.2.3