Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Cannot change default_checked_level of Sorbet when using this gem. #408

Open
shoffing opened this issue Apr 28, 2021 · 3 comments
Open

Cannot change default_checked_level of Sorbet when using this gem. #408

shoffing opened this issue Apr 28, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@shoffing
Copy link

Describe the bug:

This gem makes it impossible to set T::Configuration.default_checked_level in a Rails app.

I suspect this is the same issue as found and fixed here: sorbet/sorbet#2717 which was caused by type signatures being loaded during sorbet-runtime initialization. sorbet-rails must be doing the same thing somewhere during initialization.

Steps to reproduce:

Create a new Rails app, install sorbet-rails, set T::Configuration.default_checked_level = :tests in config/initializers/sorbet.rb, try and start the Rails app.

rails new sorbet_rails_bug
cd sorbet_rails_bug
rails webpacker:install
bundle add sorbet --group="development"
bundle add sorbet-runtime
bundle add sorbet-rails
bundle install
SRB_YES=1 bundle exec srb init
echo "T::Configuration.default_checked_level = :tests" >> config/initializers/sorbet.rb
rails s

This fails with:

/home/shoffing/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/sorbet-runtime-0.5.6393/lib/types/private/runtime_levels.rb:48:in `default_checked_level=': Set the default checked level earlier. There are already some methods whose sig blocks have evaluated which would not be affected by the new default. (RuntimeError)

Note this does not fail when sorbet-rails is not installed.

Expected behavior:

This library would not interfere with the ability to change Sorbet's default checked level.

Versions:

  • Ruby: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
  • Rails: Rails 6.0.3.6
  • Sorbet: Sorbet typechecker 0.5.6393 git ae3bc7d005f3
  • Sorbet-Rails: latest
@shoffing shoffing added the bug Something isn't working label Apr 28, 2021
@kevinjcoleman
Copy link

I'm also experiencing this. I want to iteratively add type checking, but don't want to impact the current system with possible errors. Not being able to set this up really makes things a bit more risky.

@rodrei
Copy link

rodrei commented Sep 2, 2022

I'm also seeing this error on a Rails 7 app.

@yogodoshi
Copy link

A different but related scenario: I'm also experiencing this problem because of the shopify_app gem that is making sorbet raise an error. I'm trying to disable sorbet runtime check to workaround that gem's bug.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants