Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Database.yml without whitespace

#3083

In my database.yml file, if I do not put a whitespace after the colon I get the following error. This error is caused (I think) because the yaml parser crashes if there is not a whitespace after the colon and then gives a error message about the next line it interprets

For example:
adapter: mysql
encoding: utf8
reconnect: false
database:something (note, no whitespace here)
pool: 5

would yield the following error:

c:/ruby/lib/ruby/1.8/yaml.rb:133:in load': syntax error on line 23, col 2:' (ArgumentError)

    from c:/ruby/lib/ruby/1.8/yaml.rb:133:in `load'
    from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/initializer.rb:902:in `database_configuration'
    from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/initializer.rb:437:in `initialize_database'
    from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/initializer.rb:141:in `process'
    from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/initializer.rb:113:in `send'
    from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/initializer.rb:113:in `run'
    from C:/test/config/environment.rb:9
    from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/commands/generate.rb:1
    from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from script/generate:3

Rails version: 2.3.3
Mysql gem: 2.7.3
Ruby version. 1.8.6 patchlevel 111
gem version: 1.3.5

Reported by dprickett · August 20th, 2009 @ 04:38 PM

State: invalid
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. dprickett
    dprickett

    I'm sorry, I forgot to mention this error occurs after you make the edit to database.yml and then try to create a new migration or scaffolding

    August 20th, 2009 @ 04:41 PM

  2. John Pignata
    John Pignata

    -1

    I don't think this is a bug. According to the YAML spec: Mappings use a colon and space (“: ”) to mark each key: value pair

    http://www.yaml.org/spec/1.2/spec.html#id2559116

    August 25th, 2009 @ 03:55 AM

  3. Matt Jones
    Matt Jones
    • State changed from new to invalid

    Not a bug - as John has noted, the missing space makes the file invalid YAML. Furthermore, the YAML parser is part of the Ruby standard library, so it's not a Rails issue in any case.

    September 5th, 2009 @ 05:48 AM