[Bug Report] Exception when loading signatures
jbourassa opened this issue · 0 comments
jbourassa commented
Description
Packwerk crashes on uninitialized constant Parser::AST
when running running Sorbet sig blocks:
/Users/jbourassa/3.2.1/gems/packwerk-3.0.1/lib/packwerk/file_processor.rb:61:in `block in <class:FileProcessor>': uninitialized constant Parser::AST (NameError)
params(node: Parser::AST::Node, relative_file: String).returns(T::Array[UnresolvedReference])
^^^^^^
from /Users/jbourassa/.gem/ruby/3.2.1/gems/sorbet-runtime-0.5.10712/lib/types/private/methods/_methods.rb:358:in `instance_exec'
from /Users/jbourassa/.gem/ruby/3.2.1/gems/sorbet-runtime-0.5.10712/lib/types/private/methods/_methods.rb:358:in `run_builder'
from /Users/jbourassa/.gem/ruby/3.2.1/gems/sorbet-runtime-0.5.10712/lib/types/private/methods/_methods.rb:336:in `run_sig'
from /Users/jbourassa/.gem/ruby/3.2.1/gems/sorbet-runtime-0.5.10712/lib/types/private/methods/_methods.rb:246:in `block in _on_method_added'
from /Users/jbourassa/.gem/ruby/3.2.1/gems/sorbet-runtime-0.5.10712/lib/types/private/methods/_methods.rb:447:in `run_sig_block_for_key'
from /Users/jbourassa/.gem/ruby/3.2.1/gems/sorbet-runtime-0.5.10712/lib/types/private/methods/_methods.rb:464:in `block in run_all_sig_blocks'
from /Users/jbourassa/.gem/ruby/3.2.1/gems/sorbet-runtime-0.5.10712/lib/types/private/methods/_methods.rb:461:in `loop'
from /Users/jbourassa/.gem/ruby/3.2.1/gems/sorbet-runtime-0.5.10712/lib/types/private/methods/_methods.rb:461:in `run_all_sig_blocks'
from /Users/jbourassa/.gem/ruby/3.2.1/gems/sorbet-runtime-0.5.10712/lib/types/utils.rb:83:in `run_all_sig_blocks'
from /Users/jbourassa/src/minimal-repo/config/initializers/run_all_sig_blocks.rb:1:in `<top (required)>'
[...]
To Reproduce
# Setup the Rails app
rails new --minimal packwerk_repro
cd packwerk_repro
bundle add packwerk sorbet
echo 'T::Utils.run_all_sig_blocks' > config/initializers/run_all_sig_blocks.rb
# Run it
bin/rails runner "1"
Version Information
- Packwerk: v3+
- Ruby v3.2.1
Additional Context
This is reproducible on a typical Rails app generated from Shopify's template (e.g. dev init
), and we hit this in production only when deploying our service. I can provide a bugsnag link of that's helpful, hit me up on Slack.