Sunday, October 12, 2008

Heroku database.yml and no such file to load -- sqlite3

Heroku has a little gotcha when running Rails frozen into vendor/rails. See the thread for more details. The summary is, don't do it, it's not supported.

The slightly longer answer is that Heroku loads a customized version of Rails to support their special features. This means that you must reference a version they have installed and never, ever freeze rails (you know--in vendor/rails). Currently, Heroku support 2.0.x and Rails 2.1, but can't run other versions such as edge or Rails 2.1.1. :-)

The gotcha is that instead of an error saying you've frozen Rails--don't do it! you get a number of seemingly odd errors centered around database.yml. Now Heroku generally ignores your config/database.yml file completely and deploys internally on PostgreSQL. But, in this error state, Heroku appears to be trying to run your committed database.yml file (or complain if none exists). Moreover, referencing a mysql database gives you a no socket error. Below find the full text of the stack dump for future searchers.

MissingSourceFile in DashboardsController#index

no such file to load -- sqlite3
RAILS_ROOT: /mnt/home/userapps/xxx

Application Trace | Framework Trace | Full Trace
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
vendor/rails/activesupport/lib/active_support/dependencies.rb:148:in `require'
vendor/rails/activesupport/lib/active_support/dependencies.rb:507:in `new_constants_in'
vendor/rails/activesupport/lib/active_support/dependencies.rb:148:in `require'
vendor/rails/activesupport/lib/active_support/core_ext/kernel/requires.rb:7:in `require_library_or_gem'
vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
vendor/rails/activesupport/lib/active_support/core_ext/kernel/requires.rb:5:in `require_library_or_gem'
vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:10:in `sqlite3_connection'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `send'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `new_connection'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:237:in `checkout_new_connection'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:180:in `checkout'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:176:in `loop'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:176:in `checkout'
/usr/lib/ruby/1.8/monitor.rb:238:in `synchronize'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:175:in `checkout'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:90:in `connection'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:321:in `retrieve_connection'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:121:in `retrieve_connection'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:113:in `connection'
vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
vendor/rails/actionpack/lib/action_controller/base.rb:533:in `send'
vendor/rails/actionpack/lib/action_controller/base.rb:533:in `process_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:606:in `process_without_session_management_support'
vendor/rails/actionpack/lib/action_controller/session_management.rb:134:in `process'
vendor/rails/actionpack/lib/action_controller/base.rb:401:in `process'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:179:in `handle_request'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:107:in `dispatch_unlocked'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:120:in `dispatch'
/usr/lib/ruby/1.8/thread.rb:135:in `synchronize'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:119:in `dispatch'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:129:in `dispatch_cgi'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:36:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/thin-0.8.2/lib/rack/adapter/rails.rb:54:in `serve_rails'
/usr/lib/ruby/gems/1.8/gems/thin-0.8.2/lib/rack/adapter/rails.rb:74:in `call'
/home/heroku_rack/lib/toolbar.rb:16:in `call'
/usr/bin/thin:19:in `load'
/usr/bin/thin:19
This error occurred while loading the following files:
   sqlite3
Request

Parameters:

None
Show session dump

Response

Headers:

{"cookie"=>[],
 "Content-Type"=>"",
 "Cache-Control"=>"no-cache"}

1 comments:

Veez said...

Thanks for the blog post. Saved me monkeying with trying to deploy this 2.1.1 app to Heroku much longer.