Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gem rbi generation fails with solid queue in development in rails 8 #2080

Open
mmenanno opened this issue Nov 20, 2024 · 2 comments
Open

gem rbi generation fails with solid queue in development in rails 8 #2080

mmenanno opened this issue Nov 20, 2024 · 2 comments

Comments

@mmenanno
Copy link

I've been working on spinning up a new rails server and for some some reason when I go to update the gem rbis with bin/tapioca gems I get an error when solid cable is being used for development.

/Users/USERNAME/.gem/ruby/3.3.6/gems/activerecord-8.0.0/lib/active_record/database_configurations.rb:229:in `resolve_symbol_connection': The `cable` database is not configured for the `development` environment. (ActiveRecord::AdapterNotSpecified)

  Available database configurations are:

  

        from /Users/USERNAME/.gem/ruby/3.3.6/gems/activerecord-8.0.0/lib/active_record/database_configurations.rb:179:in `resolve'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/activerecord-8.0.0/lib/active_record/connection_handling.rb:391:in `resolve_config_for_connection'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/activerecord-8.0.0/lib/active_record/connection_handling.rb:100:in `block (2 levels) in connects_to'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/activerecord-8.0.0/lib/active_record/connection_handling.rb:99:in `each'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/activerecord-8.0.0/lib/active_record/connection_handling.rb:99:in `block in connects_to'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/activerecord-8.0.0/lib/active_record/connection_handling.rb:98:in `each'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/activerecord-8.0.0/lib/active_record/connection_handling.rb:98:in `connects_to'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/solid_cable-3.0.2/app/models/solid_cable/record.rb:7:in `<class:Record>'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/solid_cable-3.0.2/app/models/solid_cable/record.rb:4:in `<module:SolidCable>'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/solid_cable-3.0.2/app/models/solid_cable/record.rb:3:in `<main>'
        from /Users/USERNAME/.rubies/ruby-3.3.6/lib/ruby/3.3.0/bundled_gems.rb:69:in `require'
        from /Users/USERNAME/.rubies/ruby-3.3.6/lib/ruby/3.3.0/bundled_gems.rb:69:in `block (2 levels) in replace_require'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/bootsnap-1.18.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/zeitwerk-2.7.1/lib/zeitwerk/core_ext/kernel.rb:26:in `require'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/solid_cable-3.0.2/app/models/solid_cable/message.rb:4:in `<module:SolidCable>'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/solid_cable-3.0.2/app/models/solid_cable/message.rb:3:in `<main>'
        from /Users/USERNAME/.rubies/ruby-3.3.6/lib/ruby/3.3.0/bundled_gems.rb:69:in `require'
        from /Users/USERNAME/.rubies/ruby-3.3.6/lib/ruby/3.3.0/bundled_gems.rb:69:in `block (2 levels) in replace_require'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/bootsnap-1.18.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/zeitwerk-2.7.1/lib/zeitwerk/core_ext/kernel.rb:26:in `require'
        from /Users/USERNAME/.gem/ruby/3.3.6/bundler/gems/tapioca-cc19ba0b523d/lib/tapioca/runtime/reflection.rb:50:in `const_get'
        from /Users/USERNAME/.gem/ruby/3.3.6/bundler/gems/tapioca-cc19ba0b523d/lib/tapioca/runtime/reflection.rb:50:in `constantize'
        from /Users/USERNAME/.gem/ruby/3.3.6/bundler/gems/tapioca-cc19ba0b523d/lib/tapioca/runtime/trackers/autoload.rb:25:in `block in eager_load_all!'
        from /Users/USERNAME/.gem/ruby/3.3.6/bundler/gems/tapioca-cc19ba0b523d/lib/tapioca/runtime/trackers/autoload.rb:50:in `with_disabled_exits'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/sorbet-runtime-0.5.11635/lib/types/private/methods/_methods.rb:279:in `bind_call'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/sorbet-runtime-0.5.11635/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
        from /Users/USERNAME/.gem/ruby/3.3.6/bundler/gems/tapioca-cc19ba0b523d/lib/tapioca/runtime/trackers/autoload.rb:20:in `eager_load_all!'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/sorbet-runtime-0.5.11635/lib/types/private/methods/_methods.rb:279:in `bind_call'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/sorbet-runtime-0.5.11635/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
        from /Users/USERNAME/.gem/ruby/3.3.6/bundler/gems/tapioca-cc19ba0b523d/lib/tapioca/loaders/gem.rb:69:in `require_gem_file'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/sorbet-runtime-0.5.11635/lib/types/private/methods/_methods.rb:279:in `bind_call'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/sorbet-runtime-0.5.11635/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
        from /Users/USERNAME/.gem/ruby/3.3.6/bundler/gems/tapioca-cc19ba0b523d/lib/tapioca/loaders/gem.rb:35:in `load'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/sorbet-runtime-0.5.11635/lib/types/private/methods/_methods.rb:279:in `bind_call'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/sorbet-runtime-0.5.11635/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
        from /Users/USERNAME/.gem/ruby/3.3.6/bundler/gems/tapioca-cc19ba0b523d/lib/tapioca/loaders/gem.rb:29:in `load_application'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/sorbet-runtime-0.5.11635/lib/types/private/methods/_methods.rb:279:in `bind_call'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/sorbet-runtime-0.5.11635/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
        from /Users/USERNAME/.gem/ruby/3.3.6/bundler/gems/tapioca-cc19ba0b523d/lib/tapioca/commands/abstract_gem.rb:189:in `block in perform_additions'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/thor-1.3.2/lib/thor/shell/basic.rb:46:in `indent'
        from /Users/USERNAME/.gem/ruby/3.3.6/bundler/gems/tapioca-cc19ba0b523d/lib/tapioca/commands/abstract_gem.rb:185:in `perform_additions'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/sorbet-runtime-0.5.11635/lib/types/private/methods/_methods.rb:279:in `bind_call'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/sorbet-runtime-0.5.11635/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
        from /Users/USERNAME/.gem/ruby/3.3.6/bundler/gems/tapioca-cc19ba0b523d/lib/tapioca/commands/gem_sync.rb:13:in `execute'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/sorbet-runtime-0.5.11635/lib/types/private/methods/_methods.rb:279:in `bind_call'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/sorbet-runtime-0.5.11635/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
        from /Users/USERNAME/.gem/ruby/3.3.6/bundler/gems/tapioca-cc19ba0b523d/lib/tapioca/commands/command.rb:27:in `block in run'
        from /Users/USERNAME/.gem/ruby/3.3.6/bundler/gems/tapioca-cc19ba0b523d/lib/tapioca.rb:24:in `block in silence_warnings'
        from /Users/USERNAME/.rubies/ruby-3.3.6/lib/ruby/3.3.0/rubygems/user_interaction.rb:46:in `use_ui'
        from /Users/USERNAME/.gem/ruby/3.3.6/bundler/gems/tapioca-cc19ba0b523d/lib/tapioca.rb:23:in `silence_warnings'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/sorbet-runtime-0.5.11635/lib/types/private/methods/_methods.rb:279:in `bind_call'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/sorbet-runtime-0.5.11635/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
        from /Users/USERNAME/.gem/ruby/3.3.6/bundler/gems/tapioca-cc19ba0b523d/lib/tapioca/commands/command.rb:26:in `run'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/sorbet-runtime-0.5.11635/lib/types/private/methods/_methods.rb:279:in `bind_call'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/sorbet-runtime-0.5.11635/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
        from /Users/USERNAME/.gem/ruby/3.3.6/bundler/gems/tapioca-cc19ba0b523d/lib/tapioca/cli.rb:314:in `gem'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/thor-1.3.2/lib/thor/command.rb:28:in `run'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/thor-1.3.2/lib/thor/invocation.rb:127:in `invoke_command'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/thor-1.3.2/lib/thor.rb:538:in `dispatch'
        from /Users/USERNAME/.gem/ruby/3.3.6/gems/thor-1.3.2/lib/thor/base.rb:584:in `start'
        from /Users/USERNAME/.gem/ruby/3.3.6/bundler/gems/tapioca-cc19ba0b523d/exe/tapioca:25:in `<top (required)>'
        from bin/tapioca:27:in `load'
        from bin/tapioca:27:in `<main>'

My database.yml is the default:

default: &default
  adapter: sqlite3
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000

development:
  primary:
    <<: *default
    database: storage/development.sqlite3
  cache:
    <<: *default
    database: storage/development_cache.sqlite3
    migrations_paths: db/cache_migrate
  queue:
    <<: *default
    database: storage/development_queue.sqlite3
    migrations_paths: db/queue_migrate
  cable:
    <<: *default
    database: storage/development_cable.sqlite3
    migrations_paths: db/cable_migrate

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: storage/test.sqlite3


# Store production database in the storage/ directory, which by default
# is mounted as a persistent Docker volume in config/deploy.yml.
production:
  primary:
    <<: *default
    database: storage/production.sqlite3
  cache:
    <<: *default
    database: storage/production_cache.sqlite3
    migrations_paths: db/cache_migrate
  queue:
    <<: *default
    database: storage/production_queue.sqlite3
    migrations_paths: db/queue_migrate
  cable:
    <<: *default
    database: storage/production_cable.sqlite3
    migrations_paths: db/cable_migrate

And I updated the default cable.yml which used to work when it was:

development:
  adapter: async

test:
  adapter: test

production:
  adapter: solid_cable
  connects_to:
    database:
      writing: cable
  polling_interval: 0.1.seconds
  message_retention: 1.day

But changing it to this broke things:

default: &default
  adapter: solid_cable
  connects_to:
    database:
      writing: cable
  polling_interval: 0.1.seconds
  message_retention: 1.day

development:
  <<: *default

test:
  adapter: test

production:
  <<: *default

Am I doing something weird here? Or is tapioca not properly handling the newer multi-database setup from rails 8?

@KaanOzkan
Copy link
Contributor

I'm not sure. You can try to see which constant being loaded in

Reflection.constantize(constant_name, inherit: true)

Are you able to load DB backed constants in your rails console with the new setup?

@mmenanno
Copy link
Author

Are you able to load DB backed constants in your rails console with the new setup?

Yup, running the server works fine, all my linters work fine, and interacting with models via the rails console all seems to work fine. It is just this process that currently fails.

Looks like the constant being loaded that fails is SolidCable::Record. I verified that I can interact with this specific constant in a rails console as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants