summaryrefslogtreecommitdiff
path: root/spec
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 /spec
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 'spec')
-rw-r--r--spec/bundler/bundler/plugin_spec.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/bundler/bundler/plugin_spec.rb b/spec/bundler/bundler/plugin_spec.rb
index 3ac7b251a3..fea3925000 100644
--- a/spec/bundler/bundler/plugin_spec.rb
+++ b/spec/bundler/bundler/plugin_spec.rb
@@ -333,5 +333,28 @@ RSpec.describe Bundler::Plugin do
end.to output("win\n").to_stdout
end
end
+
+ context "the plugin load_path is invalid" do
+ before do
+ allow(index).to receive(:load_paths).with("foo-plugin").
+ and_return(["invalid-file-name1", "invalid-file-name2"])
+ end
+
+ it "outputs a useful warning" do
+ msg =
+ "The following plugin paths don't exist: invalid-file-name1, invalid-file-name2.\n\n" \
+ "This can happen if the plugin was " \
+ "installed with a different version of Ruby that has since been uninstalled.\n\n" \
+ "If you would like to reinstall the plugin, run:\n\n" \
+ "bundler plugin uninstall foo-plugin && bundler plugin install foo-plugin\n\n" \
+ "Continuing without installing plugin foo-plugin.\n"
+
+ expect(Bundler.ui).to receive(:warn).with(msg)
+
+ Plugin.hook(Bundler::Plugin::Events::EVENT1)
+
+ expect(subject.loaded?("foo-plugin")).to be_falsey
+ end
+ end
end
end