3

私は RoR のまったくの初心者なので、このトピックに関する私の密度を許してください。

rails server コマンドを使用して WEBrick アプリケーション サーバーを起動しようとしていますが、アプリ ディレクトリ /Users/Grace/Sites/simple_cms で実行すると次のエラーが発生します。

私は以下を実行しています:

レール 3.2.13

ruby 2.0.0p0 (2013-02-24 リビジョン 39474) [x86_64-darwin12.3.0]

OS X 10.8.3

エラースタックは次のとおりです。

Grace$ rails server
=> Booting WEBrick
=> Rails 3.2.13 application starting in development on http://localhost:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/Grace/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/psych.rb:205:in `parse': (<unknown>): could not find expected ':' while scanning a simple key at line 18 column 3 (Psych::SyntaxError)
    from /Users/Grace/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/psych.rb:205:in `parse_stream'
    from /Users/Grace/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/psych.rb:153:in `parse'
    from /Users/Grace/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/psych.rb:129:in `load'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/application/configuration.rb:115:in `database_configuration'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/railtie.rb:78:in `block (2 levels) in <class:Railtie>'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `each'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/base.rb:720:in `<top (required)>'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/railtie.rb:88:in `block in <class:Railtie>'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/Grace/Sites/simple_cms/config/environment.rb:5:in `<top (required)>'
    from /Users/Grace/Sites/simple_cms/config.ru:3:in `require'
    from /Users/Grace/Sites/simple_cms/config.ru:3:in `block in <main>'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
    from /Users/Grace/Sites/simple_cms/config.ru:in `new'
    from /Users/Grace/Sites/simple_cms/config.ru:in `<main>'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands/server.rb:46:in `app'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands/server.rb:70:in `start'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands.rb:55:in `block in <top (required)>'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
    from /Users/Grace/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

psych.rb ファイルを開くと、次のように表示されます。

require 'psych.so'
require 'psych/nodes'
require 'psych/streaming'
require 'psych/visitors'
require 'psych/handler'
require 'psych/tree_builder'
require 'psych/parser'
require 'psych/omap'
require 'psych/set'
require 'psych/coder'
require 'psych/core_ext'
require 'psych/deprecated'
require 'psych/stream'
require 'psych/json/tree_builder'
require 'psych/json/stream'
require 'psych/handlers/document_stream'

###
# = Overview
#
# Psych is a YAML parser and emitter.
# Psych leverages libyaml [Home page: http://pyyaml.org/wiki/LibYAML]
# or [Git repo: https://github.com/zerotao/libyaml] for its YAML parsing

助けてください!ありがとうございました :)

4

3 に答える 3

2

私も同じ問題を抱えていました.database.ymlでインデントとスペースが正しいにもかかわらず、まだエラーが発生していました. 私の場合、application.yml の対応する行のインデントが正しくありませんでした。

于 2014-08-23T23:15:26.773 に答える
0

@Steel は非常に優れていますが、スペースを削除しても解決しません (エラーの数が増えます)。しかし実際には、このエラーは問題が database.yml にあることを示しています。

私の場合、2 つのステートメント ソケットがありました。

コードのインデントは重要です。

development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: xxx
  pool: 5
  username: xxx
  password: xxx
  socket: /socket_adress
test:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: xxx
  pool: 5
  username: xxx
  password: xxx
  socket: /socket_adress
production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: xxx
  pool: 5
  username: xxx
  password: xxx
  socket: /socket_adress
于 2014-06-03T11:08:15.237 に答える