-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add useful error message for plugin load #7639
base: master
Are you sure you want to change the base?
Add useful error message for plugin load #7639
Conversation
Thanks for opening a pull request and helping make RubyGems and Bundler better! Someone from the RubyGems team will take a look at your pull request shortly and leave any feedback. Please make sure that your pull request has tests for any changes or added functionality. We use GitHub Actions to test and make sure your change works functionally and uses acceptable conventions, you can review the current progress of GitHub Actions in the PR status window below. If you have any questions or concerns that you wish to ask, feel free to leave a comment in this PR or join our #rubygems or #bundler channel on Slack. For more information about contributing to the RubyGems project feel free to review our CONTRIBUTING guide |
Hello @sarahsehr. Code looks good, but some specs are failing, EDIT: false alarm, main branch looks ok, it was outdated tmp during my initial test. |
bundler/lib/bundler/plugin.rb
Outdated
|
||
bundler plugin install #{name} | ||
MESSAGE | ||
raise PluginError.new(message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered just warn in here and skip plugin + continue? 🤔
bundler/lib/bundler/plugin.rb
Outdated
raise PluginError.new(message) | ||
end | ||
|
||
Gem.add_to_load_path(paths) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sarahsehr this seems to fails the test (and breaks some test gem installation at the same time). add_to_load_path
is defined at
Lines 576 to 584 in c1933bf
## | |
# Add a list of paths to the $LOAD_PATH at the proper place. | |
def self.add_to_load_path(*paths) | |
@activated_gem_paths = activated_gem_paths + paths.size | |
# gem directories must come after -I and ENV['RUBYLIB'] | |
$LOAD_PATH.insert(Gem.load_path_insert_index, *paths) | |
end |
paths
array, you need to add splat (*) operator. Changing this to Gem.add_to_load_path(*paths)
should fix this. 🙏
Since this a |
@sarahsehr friendly ping, is there still interest to finish this? Happy to help or take over to fix the one blocking comment in plugin.rb. |
Thanks for the friendly ping! Coincidentally, I was planning to work on this today. :) |
We're almost done with a big rework of how plugins currently work at #6957, I wonder if that could actually fix/improve this problem. |
6694e0a
to
f285956
Compare
Thanks for pointing this out! I pulled the branch from that PR and was able to reproduce the issue, so unfortunately it doesn't. |
f285956
to
75e6bfc
Compare
@simi I have changed the output to warning and continue the install. The output looks like above (ignore the black line, that's debug output from another gem). |
end | ||
return unless all_paths_valid | ||
|
||
Gem.add_to_load_path(*paths) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are two non existing paths in the same plugin, we'll end up printing this big error block twice. I think it will read slightly better to find all invalid paths first, and then print an error including all of them. Like
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
75e6bfc
to
9d8aed8
Compare
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.
9d8aed8
to
9ad0bce
Compare
What was the end-user or developer problem that led to this PR?
When starting to work on my first issue, I found that
rake setup
failed for me. This was due to having previously installed a plugin, whose files had since been deleted (presumably when I uninstalled that version of Ruby).Fixes #7636.
What is your fix for the problem, implemented in this PR?
Check to see whether each load path for the plugin is a directory. If it is not, notify the user in a friendly message which plugin in the problem and how to resolve the issue.
Make sure the following tasks are checked