Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to install RedMine on CentOS 6.2 but I am running into difficulties when I try to access the site. Using this guide, I have configured the following in environment.rb:

# Load the rails application
require File.expand_path('../application', __FILE__)

# Make sure there's no plugin in vendor/plugin before starting
vendor_plugins_dir = File.join(Rails.root, "vendor", "plugins")
if Dir.glob(File.join(vendor_plugins_dir, "*")).any?
  $stderr.puts "Plugins in vendor/plugins (#{vendor_plugins_dir}) are no longer allowed. " +
    "Please, put your Redmine plugins in the `plugins` directory at the root of your " +
    "Redmine directory (#{File.join(Rails.root, "plugins")})"
  exit 1
end

ENV['RAILS_ENV'] ||= 'production'

#RAILS_ENV=production bundle exec rake generate_session_store
RAILS_ENV=production bundle exec rake db:migrate

# Initialize the rails application
RedmineApp::Application.initialize!

Unfortunately, I keep running into the following error:

undefined method 'db' for main:Object

I get the same problem when I try to run the command manually:

[root@nag0 config]# rake db:migrate --trace
(in /var/www/html/redmine-2.2.2)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
undefined method `db' for main:Object
/var/www/html/redmine-2.2.2/config/environment.rb:16
/usr/lib64/ruby/gems/1.8/gems/railties-3.2.11/lib/rails/application.rb:103:in `require'
/usr/lib64/ruby/gems/1.8/gems/railties-3.2.11/lib/rails/application.rb:103:in `require_environment!'
/usr/lib64/ruby/gems/1.8/gems/railties-3.2.11/lib/rails/application.rb:297:in `initialize_tasks'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:228:in `execute'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:166:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:187:in `invoke_prerequisites'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:185:in `each'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:185:in `invoke_prerequisites'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:165:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:101:in `top_level'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:101:in `top_level'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:73:in `run'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/bin/rake:33
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
Tasks: TOP => db:migrate => environment

I have configured the database.yml file with my MySQL database login/password.

Given that I am new to Ruby in general, I am sure that I am doing something wrong, but unfortunately I do not know enough about how Ruby works to troubleshoot much further.

Any suggestions are always appreciated.

share|improve this question
    
Did you run bundle install? –  Michael Hampton Feb 13 '13 at 23:37
    
Yep, I did. Your bundle is complete! Use bundle show [gemname]` to see where a bundled gem is installed` –  tacos_tacos_tacos Feb 13 '13 at 23:39

1 Answer 1

up vote 1 down vote accepted

Can you confirm that you've configured config/database.yml rather than config/db.yml? If not, you've named your database configuration file incorrectly.

You've also misread the guide. Under the section Generate the session store, commands to execute are listed - not additions to environment.rb.

Remove the lines

#RAILS_ENV=production bundle exec rake generate_session_store
RAILS_ENV=production bundle exec rake db:migrate

from your environment.rb and proceed with the guide by executing the commands in the Generate the session store at the command line instead.

share|improve this answer
    
I mis-typed, the database.yml file was named correctly. But, after removing those lines and running update_rubygems, those commands worked! –  tacos_tacos_tacos Feb 13 '13 at 23:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.