-
Notifications
You must be signed in to change notification settings - Fork 155
[Tapioca Addon] Handle missing gems gracefully in tapioca gem command #2111
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
Conversation
|
I'm not a maintainer, but I want to call out that this change would allow See: #2096 |
Can you explain some more about this use case? If I entered an invalid gem name, I would expect |
|
(and let's add a test if we choose to proceed) |
LSP add-on will supply gem names very leniently and as a result can hit this exception often. We think it's cleaner to fix it here than rescue exceptions. In your use case we'll still exit without doing much work
Yes we need a CLI tests to accompany this change. |
|
Got it. Can we detect if running through the LSP or not, and respond accordingly? |
b8e73c7 to
2d8c0ee
Compare
lib/tapioca/commands/abstract_gem.rb
Outdated
| gem = @bundle.gem(gem_name) | ||
|
|
||
| if gem.nil? | ||
| next say("Warning: Cannot find gem '#{gem_name}', skipping", :yellow) if @lsp_addon |
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.
(nit) Since say doesn't return anything meaningful, I think we shouldn't pass is it to next.
| next say("Warning: Cannot find gem '#{gem_name}', skipping", :yellow) if @lsp_addon | |
| if @lsp_addon | |
| say("Warning: Cannot find gem '#{gem_name}', skipping", :yellow) | |
| next | |
| end |
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.
Another point: I think someone else brought this up before but if we're going to make this specific to lsp_addon I'd be okay with not outputting the warning log.
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.
That's fair. It does create a bit of noise that might not be very relevant.
I'll remove the warning log.
This flag allows us to detect when the gem command is executed by the Tapioca LSP Addon.
2d8c0ee to
57f0d07
Compare
57f0d07 to
48799d0
Compare
Motivation
Currently, when a gem specified in the
tapioca gemcommand isn't found by bundler, the process fails with aThor::Error. This creates a poor user experience on the rare instances when the Tapioca LSP Addon runs the command with multiple gems where some might not be available.Implementation
With this change, when the
--lsp_addonflag is used, the command will now output a warning when a gem isn't found and continue processing other gems instead of crashing the process. This allows the Tapioca LSP Addon to handle missing gems gracefully while still generating RBIs for the available ones.Without
--lsp_addon, the command maintains its existing behaviour of failing with an error when a gem cannot be found.