Twinkle Mehta
Twinkle Mehta

Reputation: 117

When I run rails server it is showing error about database.yml

I have ROR version 4.0.0 and ruby version 2.0.0.After creating the project app when I try to run rails server it is showing me the error about yml file. The screen looks like this

    C:\Sites\app>rails s
=> Booting WEBrick
=> Rails 4.0.0 application starting in development on 
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/ap
plication/configuration.rb:113:in `rescue in database_configuration': YAML synta
x error occurred while parsing C:/Sites/app/config/database.yml. Please note tha
t YAML must be consistently indented using spaces. Tabs are not allowed. Error:
(<unknown>): could not find expected ':' while scanning a simple key at line 9 c
olumn 3 (RuntimeError)
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0
/lib/rails/application/configuration.rb:103:in `database_configuration'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4
.0.0/lib/active_record/railtie.rb:174:in `block (2 levels) in <class:Railtie>'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/lazy_load_hooks.rb:27:in `each'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/lazy_load_hooks.rb:27:in `on_load'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4
.0.0/lib/active_record/railtie.rb:173:in `block in <class:Railtie>'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0
/lib/rails/initializable.rb:30:in `instance_exec'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0
/lib/rails/initializable.rb:30:in `run'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0
/lib/rails/initializable.rb:55:in `block in run_initializers'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:150:in `block i
n tsort_each'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:183:in `block (
2 levels) in each_strongly_connected_component'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:219:in `each_st
rongly_connected_component_from'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:182:in `block i
n each_strongly_connected_component'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each_st
rongly_connected_component'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:148:in `tsort_e
ach'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0
/lib/rails/initializable.rb:54:in `run_initializers'

Please help me on it.

Upvotes: 2

Views: 8629

Answers (4)

Kevin Zhao
Kevin Zhao

Reputation: 2143

I tried to add in:

host:localhost

turns out I should have added:

host: localhost

with one space after ":"

hope this helps

Upvotes: 0

egor_hm
egor_hm

Reputation: 280

You can check your YAML file using some kind of YAML Validator

Here is your valid YAML:

development: 
  adapter: postgresql
  database: postgres
  password: 191192
  pool: 5
  timeout: 5000
  username: postgres
production: 
  adapter: postgresql
  database: postgres
  pool: 5
  timeout: 5000
test: 
  adapter: postgresql
  database: postgres
  pool: 5
  timeout: 5000

Upvotes: 2

dhouty
dhouty

Reputation: 1989

If you take a look at the trace, it tells you exactly what is wrong with your database.yml file.

"Please note that YAML must be consistently indented using spaces. Tabs are not allowed."

and

"could not find expected ':' while scanning a simple key at line 9 column 3"

So make sure that you are using spaces, not tabs, and see if you are missing a colon in line 9.

Upvotes: 0

sandymatt
sandymatt

Reputation: 5612

My guess is that you have tabs instead of spaces in your database.yml.

Quick fix in vim:

:%s/\t/  /g

Upvotes: 0

Related Questions