passenger: ActiveRecord::AdapterNotSpecified bug in latest update (6.0.5)
I performed an “apt update” on one of our Ubuntu 18.04 staging servers, and the update included Passenger version 6.0.5. Immediately after installing this update, our application started throwing the following error:
Error: The application encountered the following error: 'staging' database is not configured. Available: [] (ActiveRecord::AdapterNotSpecified)
I was able to track down the cause of the error to the following Passenger commit:
Manually reverting this commit to loader_shared_helpers.rb and restarting Nginx fixed the problem for us.
We are running a Ruby Cuba app, using ActiveRecord 5.2, with open source Passenger/Nginx, on Ubuntu 18.04.4 LTS. Ruby 2.5.1p57. Not sure if this affects Rails apps.
Happy to provide more info if needed.
Thanks
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 16
- Comments: 19 (7 by maintainers)
This is happening in a Sinatra web app as well.
I think the issue is https://github.com/phusion/passenger/commit/3790eec8191dc4725f62f770f3039eec0d022fca#diff-696bdc7bb15daaa28a5f17914682f671 calls
ActiveRecord::Base.establish_connectionwithout any arguments and for non-rails project like Sinatra will cause error because the defaultActiveRecord::Base.configurationsis empty. 😩I use the following config code to my Sinatra project as workaround:
I have a legacy application on Sinatra that uses a custom DB connection with
ActiveRecord::Base.establish_connectionthat was working till it was updated to 6.0.4. No longer works with 6.0.5.i’m not really sure that calling
ActiveRecord::Base.establish_connectionis the right thing for passenger to do, personally. we have connection logic that is set up on app initialization which is being blasted away by this.what’s the advantage of passenger doing this?
Yes, @ihower is correct. And the next version of Passenger should handle this case. Thanks to everyone who helped debug this issue.
Same here.
This seems to be the culprit: https://github.com/phusion/passenger/issues/2253 https://github.com/phusion/passenger/commit/3790eec8191dc4725f62f770f3039eec0d022fca
Same here. I am building a docker image with the phusion/passenger-ruby26 and setting my environment variables for production stage. Had to update some scripts and rebuilt my image and i’m getting
Error: The application encountered the following error: 'production' database is not configured. Available: [] (ActiveRecord::AdapterNotSpecified)I looked a lot to the updated code in search for some error in it. But is pretty much like the old code I had. Found this issue and it’s verry similar to the problem I have.
Full backtrace: