Search code examples
ruby-on-railsactiverecordrails-activerecordibm-cloud

ActiveRecord::AdapterNotSpecified - database is not configured


I have started getting this error when pushing my Ruby on Rails app to Bluemix. My app doesn't actually need a database, but I have the following in database.yml:

default: &default
  adapter: sqlite3
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: db/development.sqlite3
  
test:
  <<: *default
  database: db/test.sqlite3

production:
  <<: *default
  database: db/production.sqlite3

And in my Gemfile:

gem 'sqlite3' # Use sqlite3 as the database for Active Record

group :production do
    gem 'rails_serve_static_assets'
end

These are the errors I get:

Could not detect rake tasks
ensure you can run `$ bundle exec rake -P` against your app with no environment variables present
and using the production group of your Gemfile.
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.1/lib/active_support/values/time_zone.rb:285: warning: circular argument reference - now
DEPRECATION WARNING: Passing a string to ActiveRecord::Base.establish_connection for a configuration lookup is deprecated, please pass a symbol (:"") instead. (called from <top (required)> at /tmp/staged/app/Rakefile:6)
rake aborted!
ActiveRecord::AdapterNotSpecified: '' database is not configured. Available: ["production"]
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:257:in `resolve_symbol_connection'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:240:in `resolve_string_connection'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:267:in `resolve_hash_connection'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:228:in `resolve_connection'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:152:in `resolve'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:164:in `block in resolve_all'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:163:in `each'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:163:in `resolve_all'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/connection_handling.rb:69:in `resolve'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/core.rb:46:in `configurations='
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/core.rb:48:in `block in <module:Core>'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.1/lib/active_support/concern.rb:120:in `class_eval'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.1/lib/active_support/concern.rb:120:in `append_features'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/base.rb:297:in `include'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/base.rb:297:in `<class:Base>'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/base.rb:282:in `<module:ActiveRecord>'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/base.rb:23:in `<top (required)>'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/railtie.rb:39:in `require'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.1/lib/active_record/railtie.rb:39:in `block in <class:Railtie>'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/railties-4.1.1/lib/rails/railtie.rb:237:in `instance_exec'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/railties-4.1.1/lib/rails/railtie.rb:237:in `block in run_tasks_blocks'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/railties-4.1.1/lib/rails/railtie.rb:245:in `each'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/railties-4.1.1/lib/rails/railtie.rb:245:in `each_registered_block'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/railties-4.1.1/lib/rails/railtie.rb:237:in `run_tasks_blocks'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/railties-4.1.1/lib/rails/application.rb:361:in `block in run_tasks_blocks'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/railties-4.1.1/lib/rails/engine/railties.rb:13:in `each'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/railties-4.1.1/lib/rails/engine/railties.rb:13:in `each'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/railties-4.1.1/lib/rails/application.rb:361:in `run_tasks_blocks'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/railties-4.1.1/lib/rails/engine.rb:449:in `load_tasks'
/tmp/staged/app/Rakefile:6:in `<top (required)>'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load_rakefile'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:689:in `raw_load_rakefile'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:94:in `block in load_rakefile'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:93:in `load_rakefile'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:77:in `block in run'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:75:in `run'
/tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/bin/rake:33:in `<top (required)>'
vendor/bundle/bin/rake:16:in `load'
vendor/bundle/bin/rake:16:in `<main>'
###### WARNING:
You have not declared a Ruby version in your Gemfile.
To set your Ruby version add this line to your Gemfile:
ruby '2.2.3'

Solution

  • Looks like RAILS_ENV variable is not set. I have not used Bluemix so not sure how to export variables there. If you don't need database, you don't have to include activerecord. see following thread for more details on how to remove activerecord.