Shopify / tapioca

The swiss army knife of RBI generation
MIT License
735 stars 122 forks source link

tapioca rbi - URI::File of URI::Source does not derive from Class #1154

Closed denvermullets closed 2 years ago

denvermullets commented 2 years ago

Note: this is a Rails API

i added a couple of gems (bcrypt / jwt, if you're curious) and then updated my tapioca gem (0.10.0). now i am getting this in the Todo file and shows up when running srb tc

sorbet/rbi/gems/tapioca@0.10.0.rbi:3030: The super class URI::File of URI::Source does not derive from Class https://srb.help/5067
    3030 |class URI::Source < ::URI::File
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rbi/todo.rbi:8: URI::File defined here
     8 |module URI::File; end
        ^^^^^^^^^^^^^^^^
Errors: 1

i deleted the sorbet folder and re-initialized everything and it comes back.

here's my gemfile if that helps:

source 'https://rubygems.org'
git_source(:github) { |repo| 'https://github.com/#{repo}.git' }

ruby '3.1.2'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
gem 'rails', '~> 7.0.3.1'

gem 'bcrypt', '~> 3.1.7'
gem 'httparty'
gem 'jwt', '~> 2.2'
gem 'pg', '~> 1.1'
gem 'pry-byebug'
gem 'puma', '~> 5.0'
gem 'rack-cors'
gem 'rubocop'
gem 'sorbet', :group => :development
gem 'sorbet-runtime'
gem 'tapioca', require: false, :group => :development

gem 'bootsnap', require: false

group :development, :test do
  gem 'debug', platforms: %i[ mri mingw x64_mingw ]
end

certainly not a blocker for me but figured i'd mention it if there was a command i missed or something!

Morriar commented 2 years ago

Hey @denvermullets,

As explained in the documentation, The sorbet/rbi/todo.rbi file is used to define all unresolved constants as empty modules. Since the constants are "missing", Tapioca does not know if they should be marked as modules or classes and will use modules as a safer default. This file should be reviewed, corrected, if necessary, and then committed in your repository.

You should go over the contents of this file, remove any unnecessary constants and move the other ones to proper shims under sorbet/rbi/shims/. Note that, sometimes, constants are missing because of missing requires. Ideally you should be able to remove this file all together.

Hope this helps.

denvermullets commented 2 years ago

am i wrong in that this is coming from the tapioca gem?

Morriar commented 2 years ago

The error is indeed appearing on the tapioca RBI but the culprit is in your todo.rbi file:

    sorbet/rbi/todo.rbi:8: URI::File defined here
     8 |module URI::File; end
        ^^^^^^^^^^^^^^^^
denvermullets commented 2 years ago

ok, word, i'll poke around. thanks for the update