Skip to content

Commit 4a95bd2

Browse files
hsbtclaude
andcommitted
Check plugin file existence before loading in load_plugin
When plugins are not installed (e.g. via --no-install-plugin), the plugin files do not exist on disk. Without this check, load_plugin would attempt to load non-existent files and produce spurious LoadError warnings. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 54221ab commit 4a95bd2

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

lib/rubygems/installer.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,9 +1001,10 @@ def load_plugin
10011001
# are loaded at the same time.
10021002
return unless specs.size == 1
10031003

1004-
plugin_files = spec.plugins.map do |plugin|
1005-
File.join(@plugins_dir, "#{spec.name}_plugin#{File.extname(plugin)}")
1004+
plugin_files = spec.plugins.filter_map do |plugin|
1005+
path = File.join(@plugins_dir, "#{spec.name}_plugin#{File.extname(plugin)}")
1006+
path if File.exist?(path)
10061007
end
1007-
Gem.load_plugin_files(plugin_files)
1008+
Gem.load_plugin_files(plugin_files) unless plugin_files.empty?
10081009
end
10091010
end

0 commit comments

Comments
 (0)