You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying out Sorbet and Tapioca and I'm running into a wall when PgHero is included. Tapioca requires all your gems and loads all their classes. What appears to happen is that when PgHero is require'd PgHero::Stats tries to make a database connection immediately and fails.
What happens is that connection_config on lib/pghero.rb#215 goes looking for info about the connection established by ActiveRecord::Base but there ain't one and we get an exception. In digging around I found a code-change-less stupid hack, which is to ensure that PGHERO_DATABASE_URL env var is not blank. I added that to my Tapioca binstub and we're in business.
I don't really know what kind of change I think would make sense here. It feels like there's a lot going on just on this class being loaded, you know? I dunno.
Run the following command and get the following output
dazmin@dazmin pghero_tapioca % bundle exec tapioca init
create sorbet/config
create sorbet/tapioca/config.yml
create sorbet/tapioca/require.rb
create bin/tapioca
Retrieving index from central repository... Done
Listing gems from Gemfile.lock... Done
Removing annotations for gems that have been removed... Nothing to do
Fetching gem annotations from central repository...
Fetched actionmailer
create sorbet/rbi/annotations/actionmailer.rbi
Fetched actionpack
create sorbet/rbi/annotations/actionpack.rbi
Fetched actionview
create sorbet/rbi/annotations/actionview.rbi
Fetched activerecord
create sorbet/rbi/annotations/activerecord.rbi
Fetched activesupport
create sorbet/rbi/annotations/activesupport.rbi
Fetched rails
create sorbet/rbi/annotations/rails.rbi
Fetched railties
create sorbet/rbi/annotations/railties.rbi
Done
Removing RBI files of gems that have been removed:
Nothing to do.
Generating RBI files of gems that are added or updated:
Requiring all gems to prepare for compiling... You don't have dalli installed in your application. Please add it to your Gemfile and run bundle install
bundler: failed to load command: tapioca (/Users/dazmin/.gem/ruby/3.1.2/bin/tapioca)
/Users/dazmin/.gem/ruby/3.1.2/gems/activerecord-7.0.3.1/lib/active_record/connection_handling.rb:309:in `connection_pool': ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)
from /Users/dazmin/.gem/ruby/3.1.2/gems/activerecord-7.0.3.1/lib/active_record/connection_handling.rb:305:in `connection_db_config'
from /Users/dazmin/.gem/ruby/3.1.2/gems/pghero-2.8.3/lib/pghero.rb:216:in `connection_config'
from /Users/dazmin/.gem/ruby/3.1.2/gems/pghero-2.8.3/lib/pghero.rb:122:in `config'
from /Users/dazmin/.gem/ruby/3.1.2/gems/pghero-2.8.3/lib/pghero.rb:90:in `stats_database_url'
from /Users/dazmin/.gem/ruby/3.1.2/gems/pghero-2.8.3/lib/pghero/stats.rb:4:in `<class:Stats>'
from /Users/dazmin/.gem/ruby/3.1.2/gems/pghero-2.8.3/lib/pghero/stats.rb:2:in `<module:PgHero>'
from /Users/dazmin/.gem/ruby/3.1.2/gems/pghero-2.8.3/lib/pghero/stats.rb:1:in `<top (required)>'
from /Users/dazmin/.gem/ruby/3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in `require'
from /Users/dazmin/.gem/ruby/3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in `require'
from /Users/dazmin/.gem/ruby/3.1.2/gems/tapioca-0.10.0/lib/tapioca/runtime/reflection.rb:33:in `const_get'
from /Users/dazmin/.gem/ruby/3.1.2/gems/tapioca-0.10.0/lib/tapioca/runtime/reflection.rb:33:in `constantize'
from /Users/dazmin/.gem/ruby/3.1.2/gems/tapioca-0.10.0/lib/tapioca/runtime/trackers/autoload.rb:24:in `block in eager_load_all!'
from /Users/dazmin/.gem/ruby/3.1.2/gems/tapioca-0.10.0/lib/tapioca/runtime/trackers/autoload.rb:47:in `with_disabled_exits'
from /Users/dazmin/.gem/ruby/3.1.2/gems/sorbet-runtime-0.5.10413/lib/types/private/methods/_methods.rb:272:in `bind_call'
from /Users/dazmin/.gem/ruby/3.1.2/gems/sorbet-runtime-0.5.10413/lib/types/private/methods/_methods.rb:272:in `block in _on_method_added'
from /Users/dazmin/.gem/ruby/3.1.2/gems/tapioca-0.10.0/lib/tapioca/runtime/trackers/autoload.rb:19:in `eager_load_all!'
from /Users/dazmin/.gem/ruby/3.1.2/gems/sorbet-runtime-0.5.10413/lib/types/private/methods/_methods.rb:272:in `bind_call'
from /Users/dazmin/.gem/ruby/3.1.2/gems/sorbet-runtime-0.5.10413/lib/types/private/methods/_methods.rb:272:in `block in _on_method_added'
from /Users/dazmin/.gem/ruby/3.1.2/gems/tapioca-0.10.0/lib/tapioca/loaders/gem.rb:63:in `require_gem_file'
from /Users/dazmin/.gem/ruby/3.1.2/gems/sorbet-runtime-0.5.10413/lib/types/private/methods/_methods.rb:272:in `bind_call'
from /Users/dazmin/.gem/ruby/3.1.2/gems/sorbet-runtime-0.5.10413/lib/types/private/methods/_methods.rb:272:in `block in _on_method_added'
from /Users/dazmin/.gem/ruby/3.1.2/gems/tapioca-0.10.0/lib/tapioca/loaders/gem.rb:31:in `load'
from /Users/dazmin/.gem/ruby/3.1.2/gems/sorbet-runtime-0.5.10413/lib/types/private/methods/_methods.rb:272:in `bind_call'
from /Users/dazmin/.gem/ruby/3.1.2/gems/sorbet-runtime-0.5.10413/lib/types/private/methods/_methods.rb:272:in `block in _on_method_added'
from /Users/dazmin/.gem/ruby/3.1.2/gems/tapioca-0.10.0/lib/tapioca/loaders/gem.rb:25:in `load_application'
from /Users/dazmin/.gem/ruby/3.1.2/gems/sorbet-runtime-0.5.10413/lib/types/private/methods/_methods.rb:272:in `bind_call'
from /Users/dazmin/.gem/ruby/3.1.2/gems/sorbet-runtime-0.5.10413/lib/types/private/methods/_methods.rb:272:in `block in _on_method_added'
from /Users/dazmin/.gem/ruby/3.1.2/gems/tapioca-0.10.0/lib/tapioca/commands/gem.rb:241:in `block in perform_additions'
from /Users/dazmin/.gem/ruby/3.1.2/gems/thor-1.2.1/lib/thor/shell/basic.rb:44:in `indent'
from /Users/dazmin/.gem/ruby/3.1.2/gems/tapioca-0.10.0/lib/tapioca/commands/gem.rb:237:in `perform_additions'
from /Users/dazmin/.gem/ruby/3.1.2/gems/sorbet-runtime-0.5.10413/lib/types/private/methods/_methods.rb:272:in `bind_call'
from /Users/dazmin/.gem/ruby/3.1.2/gems/sorbet-runtime-0.5.10413/lib/types/private/methods/_methods.rb:272:in `block in _on_method_added'
from /Users/dazmin/.gem/ruby/3.1.2/gems/tapioca-0.10.0/lib/tapioca/commands/gem.rb:115:in `sync'
from /Users/dazmin/.gem/ruby/3.1.2/gems/sorbet-runtime-0.5.10413/lib/types/private/methods/_methods.rb:272:in `bind_call'
from /Users/dazmin/.gem/ruby/3.1.2/gems/sorbet-runtime-0.5.10413/lib/types/private/methods/_methods.rb:272:in `block in _on_method_added'
from /Users/dazmin/.gem/ruby/3.1.2/gems/tapioca-0.10.0/lib/tapioca/cli.rb:255:in `block in gem'
from /Users/dazmin/.gem/ruby/3.1.2/gems/tapioca-0.10.0/lib/tapioca.rb:33:in `block in silence_warnings'
from /Users/dazmin/.rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/user_interaction.rb:46:in `use_ui'
from /Users/dazmin/.gem/ruby/3.1.2/gems/tapioca-0.10.0/lib/tapioca.rb:32:in `silence_warnings'
from /Users/dazmin/.gem/ruby/3.1.2/gems/sorbet-runtime-0.5.10413/lib/types/private/methods/_methods.rb:272:in `bind_call'
from /Users/dazmin/.gem/ruby/3.1.2/gems/sorbet-runtime-0.5.10413/lib/types/private/methods/_methods.rb:272:in `block in _on_method_added'
from /Users/dazmin/.gem/ruby/3.1.2/gems/tapioca-0.10.0/lib/tapioca/cli.rb:224:in `gem'
from /Users/dazmin/.gem/ruby/3.1.2/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
from /Users/dazmin/.gem/ruby/3.1.2/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/dazmin/.gem/ruby/3.1.2/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
from /Users/dazmin/.gem/ruby/3.1.2/gems/thor-1.2.1/lib/thor/invocation.rb:116:in `invoke'
from /Users/dazmin/.gem/ruby/3.1.2/gems/tapioca-0.10.0/lib/tapioca/cli.rb:28:in `init'
from /Users/dazmin/.gem/ruby/3.1.2/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
from /Users/dazmin/.gem/ruby/3.1.2/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/dazmin/.gem/ruby/3.1.2/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
from /Users/dazmin/.gem/ruby/3.1.2/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
from /Users/dazmin/.gem/ruby/3.1.2/gems/tapioca-0.10.0/exe/tapioca:23:in `<top (required)>'
from /Users/dazmin/.gem/ruby/3.1.2/bin/tapioca:25:in `load'
from /Users/dazmin/.gem/ruby/3.1.2/bin/tapioca:25:in `<top (required)>'
from /Users/dazmin/.gem/ruby/3.1.2/gems/bundler-2.3.19/lib/bundler/cli/exec.rb:58:in `load'
from /Users/dazmin/.gem/ruby/3.1.2/gems/bundler-2.3.19/lib/bundler/cli/exec.rb:58:in `kernel_load'
from /Users/dazmin/.gem/ruby/3.1.2/gems/bundler-2.3.19/lib/bundler/cli/exec.rb:23:in `run'
from /Users/dazmin/.gem/ruby/3.1.2/gems/bundler-2.3.19/lib/bundler/cli.rb:483:in `exec'
from /Users/dazmin/.gem/ruby/3.1.2/gems/bundler-2.3.19/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
from /Users/dazmin/.gem/ruby/3.1.2/gems/bundler-2.3.19/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/dazmin/.gem/ruby/3.1.2/gems/bundler-2.3.19/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
from /Users/dazmin/.gem/ruby/3.1.2/gems/bundler-2.3.19/lib/bundler/cli.rb:31:in `dispatch'
from /Users/dazmin/.gem/ruby/3.1.2/gems/bundler-2.3.19/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
from /Users/dazmin/.gem/ruby/3.1.2/gems/bundler-2.3.19/lib/bundler/cli.rb:25:in `start'
from /Users/dazmin/.gem/ruby/3.1.2/gems/bundler-2.3.19/exe/bundle:48:in `block in <top (required)>'
from /Users/dazmin/.gem/ruby/3.1.2/gems/bundler-2.3.19/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
from /Users/dazmin/.gem/ruby/3.1.2/gems/bundler-2.3.19/exe/bundle:36:in `<top (required)>'
from /Users/dazmin/.gem/ruby/3.1.2/bin/bundle:25:in `load'
from /Users/dazmin/.gem/ruby/3.1.2/bin/bundle:25:in `<main>'
The text was updated successfully, but these errors were encountered:
Yowhattup.
I'm trying out Sorbet and Tapioca and I'm running into a wall when PgHero is included. Tapioca requires all your gems and loads all their classes. What appears to happen is that when PgHero is
require
'dPgHero::Stats
tries to make a database connection immediately and fails.What happens is that
connection_config
onlib/pghero.rb#215
goes looking for info about the connection established byActiveRecord::Base
but there ain't one and we get an exception. In digging around I found a code-change-less stupid hack, which is to ensure thatPGHERO_DATABASE_URL
env var is not blank. I added that to my Tapioca binstub and we're in business.I don't really know what kind of change I think would make sense here. It feels like there's a lot going on just on this class being loaded, you know? I dunno.
Minimal recreation, steps as follows:
rails new --minimal
The text was updated successfully, but these errors were encountered: