summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSarah Sehr <sarah.sehr@appfolio.com>2024-05-08 15:19:19 -0400
committergit <svn-admin@ruby-lang.org>2024-10-31 17:10:31 +0000
commit80fd8463536cfb1db29aa7f784b41178243524cb (patch)
tree00452d9b6074561318bd284eb18ad30c47dd674e /lib
parent66afde9ceaafe92f8727087332939bc94fadcbdf (diff)
[rubygems/rubygems] Add useful error message for plugin load
If a plugin has previously been installed, but the path is no longer valid, `rake setup` will fail with an unexpected error due to the file not existing. Instead, we want to present the user with what the issue is and how to resolve the problem. https://github.com/rubygems/rubygems/commit/0c6ad3ecbb
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/plugin.rb21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/bundler/plugin.rb b/lib/bundler/plugin.rb
index 588fa79be8..7790a3f6f8 100644
--- a/lib/bundler/plugin.rb
+++ b/lib/bundler/plugin.rb
@@ -342,7 +342,26 @@ module Bundler
# done to avoid conflicts
path = index.plugin_path(name)
- Gem.add_to_load_path(*index.load_paths(name))
+ paths = index.load_paths(name)
+ invalid_paths = paths.reject {|p| File.directory?(p) }
+
+ if invalid_paths.any?
+ Bundler.ui.warn <<~MESSAGE
+ The following plugin paths don't exist: #{invalid_paths.join(", ")}.
+
+ This can happen if the plugin was installed with a different version of Ruby that has since been uninstalled.
+
+ If you would like to reinstall the plugin, run:
+
+ bundler plugin uninstall #{name} && bundler plugin install #{name}
+
+ Continuing without installing plugin #{name}.
+ MESSAGE
+
+ return
+ end
+
+ Gem.add_to_load_path(*paths)
load path.join(PLUGIN_FILE_NAME)