Skip to content

Commit c30d74b

Browse files
authored
Ensure version from bundled_gems is used in tool/rdoc-srcdir (ruby#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.
1 parent 4245f8e commit c30d74b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tool/rdoc-srcdir

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
#!ruby -W0
22

3+
srcdir = File.dirname(__dir__)
4+
bundled_gems = File.join(srcdir, "gems/bundled_gems")
5+
versions = {}
6+
File.foreach(bundled_gems) do |line|
7+
next if line.start_with?("#") || line.strip.empty?
8+
name, version, = line.split
9+
versions[name] = version
10+
end
11+
312
%w[tsort rdoc].each do |lib|
4-
path = Dir.glob("#{File.dirname(__dir__)}/.bundle/gems/#{lib}-*").first
13+
path = File.join(srcdir, ".bundle/gems/#{lib}-#{versions[lib]}")
514
$LOAD_PATH.unshift("#{path}/lib")
615
end
716
require 'rdoc/rdoc'

0 commit comments

Comments
 (0)