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

Litestack expecting sqlite3_production_warning to be present, fails with Rails 7.2 (main branch) #105

Closed
zackgilbert opened this issue Mar 29, 2024 · 1 comment

Comments

@zackgilbert
Copy link
Contributor

Hello. Tried to get litestack working with the latest (as of this writing) Rails main branch and it's currently failing because in Rails 7.2.0-alpha, they removed the sqlite3_production_warning config warning about using SQLite in production.

When I try to do anything after adding the gem, I get the following:

/Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-a2a870a7360e/activerecord/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `sqlite3_production_warning=' for ActiveRecord::Base:Class (NoMethodError)
	from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-a2a870a7360e/activerecord/lib/active_record/railtie.rb:261:in `block (3 levels) in <class:Railtie>'
	from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-a2a870a7360e/activerecord/lib/active_record/railtie.rb:251:in `each'
	from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-a2a870a7360e/activerecord/lib/active_record/railtie.rb:251:in `block (2 levels) in <class:Railtie>'
	from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-a2a870a7360e/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-a2a870a7360e/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-a2a870a7360e/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-a2a870a7360e/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-a2a870a7360e/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-a2a870a7360e/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-a2a870a7360e/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-a2a870a7360e/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-a2a870a7360e/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-a2a870a7360e/activerecord/lib/active_record/railtie.rb:65:in `block in <class:Railtie>'
	from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-a2a870a7360e/railties/lib/rails/railtie.rb:272:in `block in run_console_blocks'
	from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-a2a870a7360e/railties/lib/rails/railtie.rb:297:in `each'
	from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-a2a870a7360e/railties/lib/rails/railtie.rb:297:in `each_registered_block'
	from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-a2a870a7360e/railties/lib/rails/railtie.rb:272:in `run_console_blocks'
	from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-a2a870a7360e/railties/lib/rails/application.rb:606:in `block in run_console_blocks'
	from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-a2a870a7360e/railties/lib/rails/engine/railties.rb:15:in `each'
	from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-a2a870a7360e/railties/lib/rails/engine/railties.rb:15:in `each'
	from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-a2a870a7360e/railties/lib/rails/application.rb:606:in `run_console_blocks'
	from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-a2a870a7360e/railties/lib/rails/engine.rb:456:in `load_console'
	from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-a2a870a7360e/railties/lib/rails/commands/console/console_command.rb:84:in `initialize'
	from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-a2a870a7360e/railties/lib/rails/commands/console/console_command.rb:68:in `new'
	from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-a2a870a7360e/railties/lib/rails/commands/console/console_command.rb:68:in `start'
	from /Users/zackgilbert/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-a2a870a7360e/railties/lib/rails/commands/console/console_command.rb:144: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-a2a870a7360e/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-a2a870a7360e/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-a2a870a7360e/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-a2a870a7360e/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-a2a870a7360e/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-a2a870a7360e/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>'

Steps to reproduce:

I used the following rails new command:

rails new project_name --main

then:

bundle add litestack

I'm then no longer able to do anything (rails c, bin/dev, rails generate litestack:install, etc) without receiving the above error.

@zackgilbert
Copy link
Contributor Author

It looks like it's because

app.config.active_record.sqlite3_production_warning = false
isn't checking to see if config.active_record.sqlite3_production_warning exists.

This is how Rails handles this check now: https://github.com/rails/rails/blob/main/activerecord/lib/active_record/railtie.rb#L201C7-L201C64

So wrapping:

if config.active_record.key?(:sqlite3_production_warning)

around it might be the best option?

zackgilbert added a commit to zackgilbert/litestack that referenced this issue Mar 29, 2024
…o false in railtie.rb

As mentioned in oldmoe#105, the new Rails main (7.2.0-alpha) removes `config.active_record.sqlite3_production_warning` and so the litestack railtie attempt to set it to false fails. This is an attempt to fix that.
@oldmoe oldmoe closed this as completed May 8, 2024
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