Create Tapioca exceptions rather than relying on `Thor::Error`
Reliance of Thor::Error and exit_on_failure? is growing and is being used by Tapioca internals. Instead we can use our own exception and have more control over how to handle it.
Hey i'm new to this, wanting to take a look at this, is this still open?
Hi @drewhoffer, yes it's still open! Main goal would be to replace Thor::Error calls with a tapioca error class and instead of relying on exit_on_failure? implement our own rescue/exit logic.
There's also an addon_mode that we want to silently terminate RBI generation and keep the tapioca process alive instead of exiting like we do when using tapioca from the CLI, context.
Maybe we could have the rescue earlier, it could be done by the server_addon for addon_mode and the exe for CLI mode.
cc @paracycle do you have something you want to add/modify?
Hey! I've opened a PR for this guy and would appreciate any feedback anyone can provide (I'm new to working on developer tools).
One thing I ran into while getting started/into to this codebase was:
When running the tests locally, I had some failing tests due to the Google::Protobuf::DescriptorPool. It seems the build method isn't available in newer versions of the protobuf gem, When i manually installed an older version gem "google-protobuf", "~> 3.19" all tests were then green.
If there is anything I could do (open an issue/open a pr) please let me know I'd be happy to help! Might be worth noting somewhere in the contributor docs if others run into the same issue.
Output of tests was:
Tapioca
Dsl
Compilers
ProtobufSpec
Tapioca
Dsl
Compilers
Protobuf
gather_constants
it gathers only classes with Protobuf Module ERROR (0.16s)
Minitest::UnexpectedError: NoMethodError: undefined method `build' for an instance of Google::Protobuf::DescriptorPool
/tmp/.../lib/cart_pb.rb:6:in `<main>'
.../lib/ruby/.../bundled_gems.rb:74:in `require'
.../lib/ruby/.../bundled_gems.rb:74:in `block (2 levels) in replace_require'
spec/tapioca/dsl/compilers/protobuf_spec.rb:601:in `block (2 levels) in add_proto_file'
lib/tapioca.rb:20:in `block in silence_warnings'
.../rubygems/user_interaction.rb:46:in `use_ui'
lib/tapioca.rb:19:in `silence_warnings'
spec/tapioca/dsl/compilers/protobuf_spec.rb:601:in `block in add_proto_file'
<internal:kernel>:90:in `tap'
spec/tapioca/dsl/compilers/protobuf_spec.rb:595:in `add_proto_file'
it gathers no constants if there are no Google::Protobuf classesERROR (0.14s)
Minitest::UnexpectedError: NoMethodError: undefined method `build' for an instance of Google::Protobuf::DescriptorPool
/tmp/.../lib/content_pb.rb:6:in `<main>'
.../lib/ruby/.../bundled_gems.rb:74:in `require'
.../lib/ruby/.../bundled_gems.rb:74:in `block (2 levels) in replace_require'
spec/tapioca/dsl/compilers/protobuf_spec.rb:601:in `block (2 levels) in add_proto_file'
lib/tapioca.rb:20:in `block in silence_warnings'
.../rubygems/user_interaction.rb:46:in `use_ui'
lib/tapioca.rb:19:in `silence_warnings'
spec/tapioca/dsl/compilers/protobuf_spec.rb:601:in `block in add_proto_file'
<internal:kernel>:90:in `tap'
spec/tapioca/dsl/compilers/protobuf_spec.rb:595:in `add_proto_file'
Thanks @drewhoffer feel free to open an issue with that output. I assume it only happens locally, we usually don't run the full test suite locally and must have missed it.
Yeah just locally on my machine. Unfortunately I don't remember the exact fix but if needed I can take a look this week and confirm. IIRC it was simply specifying 3.19 for google-protobuf #2327
@KaanOzkan i must have forgotten to tag this with a closes # but this should be closed by #2322