new install: RAILS_ENV=production bundle exec rake db:migrate fails with NameError: uninitialized constant Blog

Added by David Gessel almost 2 years ago

In a new install on a fresh jail, (FreeBSD 10.1) connecting to a remote database server but with a freshly created "redmine" database and "redmine" user, running:

$ RAILS_ENV=production bundle exec rake db:migrate --trace

Yields

** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
NameError: uninitialized constant Blog
/usr/local/www/redmine/config/initializers/secret_token.rb:7:in `<top (required)>'
/usr/local/lib/ruby/gems/2.1/gems/railties-3.2.22/lib/rails/engine.rb:593:in `block (2 levels) in <class:Engine>'
/usr/local/lib/ruby/gems/2.1/gems/railties-3.2.22/lib/rails/engine.rb:592:in `each'
/usr/local/lib/ruby/gems/2.1/gems/railties-3.2.22/lib/rails/engine.rb:592:in `block in <class:Engine>'
/usr/local/lib/ruby/gems/2.1/gems/railties-3.2.22/lib/rails/initializable.rb:30:in `instance_exec'
/usr/local/lib/ruby/gems/2.1/gems/railties-3.2.22/lib/rails/initializable.rb:30:in `run'
/usr/local/lib/ruby/gems/2.1/gems/railties-3.2.22/lib/rails/initializable.rb:55:in `block in run_initializers'
/usr/local/lib/ruby/gems/2.1/gems/railties-3.2.22/lib/rails/initializable.rb:54:in `each'
/usr/local/lib/ruby/gems/2.1/gems/railties-3.2.22/lib/rails/initializable.rb:54:in `run_initializers'
/usr/local/lib/ruby/gems/2.1/gems/railties-3.2.22/lib/rails/application.rb:136:in `initialize!'
/usr/local/lib/ruby/gems/2.1/gems/railties-3.2.22/lib/rails/railtie/configurable.rb:30:in `method_missing'
/usr/local/www/redmine/config/environment.rb:14:in `<top (required)>'
/usr/local/lib/ruby/gems/2.1/gems/railties-3.2.22/lib/rails/application.rb:103:in `require_environment!'
/usr/local/lib/ruby/gems/2.1/gems/railties-3.2.22/lib/rails/application.rb:305:in `block (2 levels) in initialize_tasks'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.1/monitor.rb:211:in `mon_synchronize'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/lib/rake/task.rb:201:in `block in invoke_prerequisites'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/lib/rake/task.rb:199:in `each'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/lib/rake/task.rb:199:in `invoke_prerequisites'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/lib/rake/task.rb:178:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.1/monitor.rb:211:in `mon_synchronize'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/usr/local/lib/ruby/gems/2.1/gems/rake-10.4.2/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

Unlike some other users with similar problems,

$ bundle exec rake generate_secret_token

works... I'm at a loss, though I had to
  1. cp /usr/local/lib/ruby/gems/2.1/gems/railties-3.2.22/guides/code/getting_started/config/initializers/secret_token.rb /usr/local/www/redmine/config/initializers/secret_token.rb

Because secret_tokens.rb wasn't there after the install. Perhaps another missing file?

-David

Replies (2)

RE: new install: RAILS_ENV=production bundle exec rake db:migrate fails with NameError: uninitialized constant Blog - Added by David Gessel almost 2 years ago

Seemed to be a permissions problem. On FreeBSD it is important to:


chgrp -R redmine /usr/local/www/redmine
chown -R redmine /usr/local/www/redmine
and
su redmine before
bundle install --without development test
bundle exec rake generate_secret_token

RE: new install: RAILS_ENV=production bundle exec rake db:migrate fails with NameError: uninitialized constant Blog - Added by Toshi MARUYAMA almost 2 years ago

David Gessel wrote:

$ bundle exec rake generate_secret_token

works... I'm at a loss, though I had to
  1. cp /usr/local/lib/ruby/gems/2.1/gems/railties-3.2.22/guides/code/getting_started/config/initializers/secret_token.rb /usr/local/www/redmine/config/initializers/secret_token.rb

Because secret_tokens.rb wasn't there after the install. Perhaps another missing file?

secret_token.rb is generated by source:tags/3.2.0/lib/tasks/initializers.rake .

(1-2/2)