Skip to content

Conversation

ajitdsa
Copy link

@ajitdsa ajitdsa commented Sep 30, 2025

Summary

This PR fixes a compatibility issue with Rails 8.
In Rails 8, the sqlite3_production_warning configuration key and its writer method (ActiveRecord::Base.sqlite3_production_warning=) were removed.
The current litestack Railtie still sets this flag unconditionally, which causes Rails 8 applications to fail at boot with:

Changes

  • Update lib/litestack/railtie.rb initializer:
    • On Rails < 8: keep existing behavior (sqlite3_production_warning = false).
    • On Rails ≥ 8: remove the key from config.active_record so ActiveRecord does not attempt to apply it.

Why

The entire purpose of litestack is to make SQLite production-ready. Disabling the Rails “don’t use SQLite in production” warning is still important for Rails 6/7.
However, since Rails 8 removed this config entirely, litestack should not attempt to set it anymore.

Impact

  • Rails 6/7: behavior unchanged.
  • Rails 8: litestack loads without error, and applications can run normally.

Example

Before this change, Rails 8 apps using litestack crashed during boot.
After applying this change, the same apps boot cleanly:

# Gemfile
gem "litestack", github: "oldmoe/litestack", branch: "rails8-fix"

One more note:

In my app, I had added some debugging in my config/application.rb thusly:

config.after_initialize do
  keys =
    if config.active_record.respond_to?(:to_h)
      config.active_record.to_h.keys
    elsif config.active_record.respond_to?(:each_pair)
      k = []
      config.active_record.each_pair { |key, _| k << key }
      k
    else
      []
    end
  Rails.logger.warn("AR config keys: #{keys.inspect}")
end

With this PR, sqlite3_production_warning was not included in the keys in my Rails 8 app.

…ion_warning

Rails 8 removed the `sqlite3_production_warning` config and its writer
method from ActiveRecord::Base. The litestack Railtie was still setting
this flag, which caused boot-time NoMethodError in Rails 8 apps.

This patch updates `lib/litestack/railtie.rb` to:
- Delete the `:sqlite3_production_warning` key when running on Rails 8+,
  so ActiveRecord doesn’t try to apply it.
- Preserve the old behavior (`sqlite3_production_warning = false`) on
  Rails 6/7, where the key and writer still exist.

This allows litestack to run cleanly on Rails 8 without crashing, while
remaining compatible with older Rails versions.
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

Successfully merging this pull request may close these issues.

1 participant