diff options
| author | Stan Lo <stan001212@gmail.com> | 2026-04-10 15:44:58 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-10 15:44:58 +0100 |
| commit | c30d74b3e2522c081e083cc860646b7a43c5511f (patch) | |
| tree | 8d782a24fac0560fc86f5815bd93b306da9daca7 | |
| parent | 4245f8e1c8862852a9295c0fdee3aa1b09a567ed (diff) | |
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.
| -rwxr-xr-x | tool/rdoc-srcdir | 11 |
1 files changed, 10 insertions, 1 deletions
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' |
