posty / posty_api

Utility to administrate mailserver based on postfix and dovecot
www.posty-soft.org
Other
85 stars 19 forks source link

ActiveRecord::AdapterNotSpecified error when running rake db:migrate #5

Closed arioch closed 10 years ago

arioch commented 10 years ago

I'm running into the following error:

# bundle exec rake db:migrate --trace
or
# RAILS_ENV=production RACK_ENV=production bundle exec rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
ActiveRecord::AdapterNotSpecified
/var/lib/gems/1.9.1/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_specification.rb:24:in `spec'
/var/lib/gems/1.9.1/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
/usr/share/posty/api/config/application.rb:12:in `<top (required)>'
/usr/share/posty/api/config/environment.rb:3:in `require'
/usr/share/posty/api/config/environment.rb:3:in `<top (required)>'
/usr/share/posty/api/Rakefile:3:in `require'
/usr/share/posty/api/Rakefile:3:in `block in <top (required)>'
/var/lib/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/var/lib/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/var/lib/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/var/lib/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/var/lib/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/var/lib/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/var/lib/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:197:in `block in invoke_prerequisites'
/var/lib/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:195:in `each'
/var/lib/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:195:in `invoke_prerequisites'
/var/lib/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:174:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/var/lib/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/var/lib/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/var/lib/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/var/lib/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/var/lib/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/var/lib/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/var/lib/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/var/lib/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/var/lib/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/var/lib/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/var/lib/gems/1.9.1/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:23:in `load'
/usr/local/bin/rake:23:in `<main>'
Tasks: TOP => db:migrate => environment

Which lead me to config/database.yml. However adapter is filled-out.

# cat config/database.yml
production:
  adapter: mysql2
  database: posty
  encoding: utf8
  host: localhost
  password: posty
  pool: 5
  port: 3306
  reconnect: false
  socket: /var/run/mysqld/mysqld.sock
  username: posty

I'm running Ruby 1.9.3 on Debian 7:

# ruby --version
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

And the following gems are installed:

# bundle install
Using rake (10.1.0)
Using actionpack (1.4.0)
Using actionmailer (0.6.1)
Using i18n (0.6.9)
Using multi_json (1.8.2)
Using activesupport (3.2.16)
Using builder (3.0.4)
Using activemodel (3.2.16)
Using arel (3.0.3)
Using tzinfo (0.3.38)
Using activerecord (3.2.16)
Using descendants_tracker (0.0.3)
Using ice_nine (0.10.0)
Using axiom-types (0.0.5)
Using coercible (1.0.0)
Using equalizer (0.0.8)
Using hashie (2.0.5)
Using multi_xml (0.5.5)
Using rack (1.5.2)
Using rack-accept (0.4.5)
Using rack-mount (0.8.3)
Using virtus (1.0.1)
Using grape (0.4.1)
Using kramdown (1.3.0)
Using grape-swagger (0.6.0)
Using json (1.7.7)
Using mysql2 (0.3.14)
Using rack-cors (0.2.9)
Using rails (0.9.5)
Using valuable (0.9.8)
Using schema_plus (0.4.1)
Using bundler (1.3.5)

Any pointers how to get this running?

chicobico commented 10 years ago

Is it possible that the production environment is not set in RACK_ENV? Check RACK_ENV or add development section to the database.yml

arioch commented 10 years ago

Just to be sure I've added development to database.yml. Same error. Same goes for the RACK_ENV parameter.

chicobico commented 10 years ago

Not RAILS_ENV RACK_ENV is the correct one.

If RACK_ENV is not set the fallback is "development"

arioch commented 10 years ago

My apologies I must've misread the first time. I've updated my previous comment.

The same error occurs on both Debian 7 and Ubuntu 12.04.

chicobico commented 10 years ago

Try adding the "test" section.

My database.yml:

development:
 adapter: mysql2
 encoding: utf8
 reconnect: false
 database: posty_api_development
 pool: 5
 username: user
 password: pass
 socket: /var/mysql/mysql.sock
test:
 adapter: mysql2
 encoding: utf8
 reconnect: false
 database: posty_api_test
 pool: 5
 username: user
 password: pass
 socket: /var/mysql/mysql.sock
hashimdevelop commented 9 years ago

While set the Environment please make sure the space after the ENVIRONMENT..(EX : set RAILS_ENV=development)