note: I'm not using and I want to know if it is possible without sorbet-rails
.
I'm trying to add sorbet to an existing/standard Rails 7 application.
I followed the instruction here: https://sorbet.org/docs/adopting.
I added the gems to the Gemfile followed by bundle install
.
gem 'sorbet', :group => :development
gem 'sorbet-runtime'
gem 'tapioca', require: false, :group => :development
After that:
bundle exec tapioca init
bin/tapioca dsl
bin/tapioca gem
bin/tapioca require
bin/tapioca gem --all
bin/tapioca annotations
After running all that, if I ran bundle exec srb tc
, I get about 23 errors. Most of them related to generated rbi files. For exemple:
...
sorbet/rbi/dsl/sessions_controller.rbi:19: Unable to resolve constant ActionHelper https://srb.help/5002
19 | include ::Turbo::Streams::ActionHelper
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sorbet/rbi/dsl/rails/conductor/base_controller.rbi:22: Unable to resolve constant ActionHelper https://srb.help/5002
22 | include ::Turbo::Streams::ActionHelper
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sorbet/rbi/dsl/rails/conductor/base_controller.rbi:22: Unable to resolve constant ActionHelper https://srb.help/5002
22 | include ::Turbo::Streams::ActionHelper
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sorbet/rbi/dsl/rails/conductor/action_mailbox/incinerates_controller.rbi:19: Unable to resolve constant ActionHelper https://srb.help/5002
19 | include ::Turbo::Streams::ActionHelper
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sorbet/rbi/dsl/rails/conductor/action_mailbox/incinerates_controller.rbi:19: Unable to resolve constant ActionHelper https://srb.help/5002
19 | include ::Turbo::Streams::ActionHelper
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Errors: 23
After applying a workaround for the Turbo issues described here (https://github.com/Shopify/tapioca/issues/671), I'm left with issues related to .require method not found.
app/controllers/people_controller.rb:48: Method permit does not exist on String component of T.any(String, Numeric, T::Array[T.untyped], ActionController::Parameters) https://srb.help/7003
48 | params.require(:person).permit(
^^^^^^
Got T.any(String, Numeric, T::Array[T.untyped], ActionController::Parameters) originating from:
app/controllers/people_controller.rb:48:
48 | params.require(:person).permit(
^^^^^^^^^^^^^^^^^^^^^^^
Did you mean format? Use `-a` to autocorrect
app/controllers/people_controller.rb:48: Replace with format
48 | params.require(:person).permit(
^^^^^^
https://github.com/sorbet/sorbet/tree/c77e3a550a6bb9c1a0772fabf433d6763a86f33d/rbi/core/kernel.rbi#L1547: Defined here
1547 | def format(format, *args); end
^^^^^^^^^^^^^^^^^^^^^^^^^
app/controllers/people_controller.rb:48: Method permit does not exist on Numeric component of T.any(String, Numeric, T::Array[T.untyped], ActionController::Parameters) https://srb.help/7003
48 | params.require(:person).permit(
^^^^^^
Got T.any(String, Numeric, T::Array[T.untyped], ActionController::Parameters) originating from:
app/controllers/people_controller.rb:48:
48 | params.require(:person).permit(
^^^^^^^^^^^^^^^^^^^^^^^
Did you mean format? Use `-a` to autocorrect
app/controllers/people_controller.rb:48: Replace with format
48 | params.require(:person).permit(
^^^^^^
https://github.com/sorbet/sorbet/tree/c77e3a550a6bb9c1a0772fabf433d6763a86f33d/rbi/core/kernel.rbi#L1547: Defined here
1547 | def format(format, *args); end
^^^^^^^^^^^^^^^^^^^^^^^^^
app/controllers/people_controller.rb:48: Method permit does not exist on T::Array[T.untyped] component of T.any(String, Numeric, T::Array[T.untyped], ActionController::Parameters) https://srb.help/7003
48 | params.require(:person).permit(
^^^^^^
Got T.any(String, Numeric, T::Array[T.untyped], ActionController::Parameters) originating from:
app/controllers/people_controller.rb:48:
48 | params.require(:person).permit(
^^^^^^^^^^^^^^^^^^^^^^^
Did you mean format? Use `-a` to autocorrect
app/controllers/people_controller.rb:48: Replace with format
48 | params.require(:person).permit(
^^^^^^
https://github.com/sorbet/sorbet/tree/c77e3a550a6bb9c1a0772fabf433d6763a86f33d/rbi/core/kernel.rbi#L1547: Defined here
1547 | def format(format, *args); end
^^^^^^^^^^^^^^^^^^^^^^^^^
Errors: 3
Is there anything missing? What is the proper way of doing this?
Note: workaround for the .permit issue can be found here https://github.com/Shopify/tapioca/issues/1122
The turbo ones are a known issue, you can take a look at https://github.com/Shopify/tapioca/issues/671 for a workaround.