From d5c54cf804d8c886294100eac524f6ed6b82a7b9 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Mon, 20 Apr 2020 15:13:21 -0700 Subject: [PATCH] Also load plugins from RUBYLIB --- bundler/lib/bundler/installer.rb | 1 + bundler/lib/bundler/rubygems_integration.rb | 4 ++++ bundler/spec/commands/install_spec.rb | 10 ++++++++++ 3 files changed, 15 insertions(+) diff --git a/bundler/lib/bundler/installer.rb b/bundler/lib/bundler/installer.rb index e08cc9722bca..a3172e1cd9e9 100644 --- a/bundler/lib/bundler/installer.rb +++ b/bundler/lib/bundler/installer.rb @@ -243,6 +243,7 @@ def load_plugins end end.flatten Bundler.rubygems.load_plugin_files(path_plugin_files) + Bundler.rubygems.load_env_plugins end def ensure_specs_are_compatible! diff --git a/bundler/lib/bundler/rubygems_integration.rb b/bundler/lib/bundler/rubygems_integration.rb index a728e1e27daa..43871250d226 100644 --- a/bundler/lib/bundler/rubygems_integration.rb +++ b/bundler/lib/bundler/rubygems_integration.rb @@ -227,6 +227,10 @@ def load_plugin_files(files) Gem.load_plugin_files(files) if Gem.respond_to?(:load_plugin_files) end + def load_env_plugins + Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins) + end + def ui=(obj) Gem::DefaultUserInteraction.ui = obj end diff --git a/bundler/spec/commands/install_spec.rb b/bundler/spec/commands/install_spec.rb index 0d17e7900eaf..d5a22c07956a 100644 --- a/bundler/spec/commands/install_spec.rb +++ b/bundler/spec/commands/install_spec.rb @@ -432,6 +432,16 @@ gem 'foo' G end + + it "loads env plugins" do + plugin_msg = "hello from an env plugin!" + create_file "plugins/rubygems_plugin.rb", "puts '#{plugin_msg}'" + install_gemfile <<-G, :env => { "RUBYLIB" => bundled_app("plugins/").to_s } + source "#{file_uri_for(gem_repo1)}" + gem 'foo' + G + expect(last_command.stdboth).to include(plugin_msg) + end end describe "Ruby version in Gemfile.lock" do