oldmoe / litestack

MIT License
1.02k stars 56 forks source link

Database configuration specifies 'litedb' adapter but that adapter has not been registered. #107

Closed zackgilbert closed 4 months ago

zackgilbert commented 5 months ago

I successfully got litestack gem installed (using this fork of the fix for Rails 7.2.0-alpha: https://github.com/oldmoe/litestack/pull/106) but now whenever I try to do anything related to the database (like running: rake db:setup or running the rails generator for models), I get the following error:

rake aborted!
ActiveRecord::AdapterNotFound: Database configuration specifies 'litedb' adapter but that adapter has not been registered. Ensure that the adapter in the Gemfile is at the latest version. If it is, then the adapter may need to be modified. (ActiveRecord::AdapterNotFound)
<internal:/Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
<internal:/Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
Tasks: TOP => db:setup => db:create => db:load_config
(See full trace by running task with --trace)

Am I missing some step or could this be another issue with the Rails main branch? Or maybe something else?

aaoafk commented 5 months ago

I wonder if you need to do a look up the rake task dependency list the answer may be there

natematykiewicz commented 5 months ago

Do you have litestack higher up in your Gemfile than rails? Because this line seems to assume Rails is loaded first.

It feels like it should be moved to the Railtie in an ActiveRecord on_load hook.

zackgilbert commented 5 months ago

I wonder if you need to do a look up the rake task dependency list the answer may be there

Apologies, not entirely sure what this means. But I can see if I can dedicate some time to troubleshoot the issue a bit more. Was also going to see if this same issue is happening on stable 7.1 rails.

zackgilbert commented 5 months ago

Do you have litestack higher up in your Gemfile than rails? Because this line seems to assume Rails is loaded first.

Litestack gem is at the bottom of my Gemfile currently.

zackgilbert commented 5 months ago

I have confirmed that this is probably a conflict with Rails 7.2.0-alpha (main branch). What I did to test this:

On stable (7.1) branch:

rails new project_name_stable --css=tailwind --asset-pipeline=propshaft --skip-test --skip-system-test --skip-action-mailbox
cd project_name_stable
bundle add litestack
rails generate litestack:install
rails app:template LOCATION='https://avohq.io/app-template'
rake db:setup

Works no problem.

On main (7.2.0-alpha) branch:

rails new project_name_main --main --css=tailwind --asset-pipeline=propshaft --skip-test --skip-system-test --skip-action-mailbox
cd project_name_main
bundle add litestack
# Note: I have to update my Gemfile to point to my fork with the sqlite3_production_warning fix to be able to use the gem
rails generate litestack:install
rails app:template LOCATION='https://avohq.io/app-template'

When I try to bundle, I noticed:

$ bundle
Fetching https://github.com/zackgilbert/litestack.git
Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Using rack 2.2.9 (was 3.0.10)
Using rack-session 1.0.2 (was 2.0.0)
Using rackup 1.0.0 (was 2.1.0)
Using hanami-router 2.1.0 (was 0.6.2)
Bundle complete! 18 Gemfile dependencies, 112 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

And when I ran a model generation, I got this full stack trace:

$ rails g model Project title:string summary:string link_url:string price:string experience:string
/Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/activerecord/lib/active_record/connection_adapters.rb:85:in `resolve': Database configuration specifies 'litedb' adapter but that adapter has not been registered. Ensure that the adapter in the Gemfile is at the latest version. If it is, then the adapter may need to be modified. (ActiveRecord::AdapterNotFound)
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/activerecord/lib/active_record/database_configurations/database_config.rb:18:in `adapter_class'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/activerecord/lib/active_record/database_configurations/database_config.rb:26:in `validate!'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/activerecord/lib/active_record/connection_adapters/abstract/connection_handler.rb:268:in `resolve_pool_config'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/activerecord/lib/active_record/connection_adapters/abstract/connection_handler.rb:116:in `establish_connection'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/activerecord/lib/active_record/connection_handling.rb:53:in `establish_connection'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/activerecord/lib/active_record/railtie.rb:273:in `block (2 levels) in <class:Railtie>'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/activesupport/lib/active_support/lazy_load_hooks.rb:97:in `class_eval'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/activesupport/lib/active_support/lazy_load_hooks.rb:97:in `block in execute_hook'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/activesupport/lib/active_support/lazy_load_hooks.rb:87:in `with_execution_control'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/activesupport/lib/active_support/lazy_load_hooks.rb:92:in `execute_hook'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/activesupport/lib/active_support/lazy_load_hooks.rb:78:in `block in run_load_hooks'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/activesupport/lib/active_support/lazy_load_hooks.rb:77:in `each'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/activesupport/lib/active_support/lazy_load_hooks.rb:77:in `run_load_hooks'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/activerecord/lib/active_record/base.rb:337:in `<module:ActiveRecord>'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/activerecord/lib/active_record/base.rb:15:in `<main>'
    from <internal:/Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
    from <internal:/Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/zeitwerk-2.6.13/lib/zeitwerk/kernel.rb:34:in `require'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/railties/lib/rails/generators/generated_attribute.rb:69:in `dangerous_name?'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/railties/lib/rails/generators/generated_attribute.rb:46:in `parse'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/railties/lib/rails/generators/named_base.rb:184:in `block in parse_attributes!'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/railties/lib/rails/generators/named_base.rb:183:in `map'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/railties/lib/rails/generators/named_base.rb:183:in `parse_attributes!'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/railties/lib/rails/generators/named_base.rb:17:in `initialize'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/railties/lib/rails/generators/model_helpers.rb:27:in `initialize'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/group.rb:226:in `new'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/group.rb:226:in `dispatch'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/base.rb:584:in `start'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/railties/lib/rails/generators.rb:262:in `invoke'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/railties/lib/rails/commands/generate/generate_command.rb:26:in `perform'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/railties/lib/rails/command/base.rb:178:in `invoke_command'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/railties/lib/rails/command/base.rb:73:in `perform'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/railties/lib/rails/command.rb:71:in `block in invoke'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/railties/lib/rails/command.rb:149:in `with_argv'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/railties/lib/rails/command.rb:69:in `invoke'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-0033d4623693/railties/lib/rails/commands.rb:18:in `<main>'
    from <internal:/Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
    from <internal:/Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
    from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
    from bin/rails:4:in `<main>'

Hope this helps.