我要在rails应用程序中使用aws-sdk
gem。问题是每当我将它添加到我的gemfile
时,rails服务器都无法启动并给我以下错误:
$ rails s
=> Booting WEBrick
=> Rails 3.2.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/psycho/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/psych.rb:203:in `parse': (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 1 (Psych::SyntaxError)
from /home/psycho/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/psych.rb:203:in `parse_stream'
from /home/psycho/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/psych.rb:151:in `parse'
from /home/psycho/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/psych.rb:127:in `load'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/aws-sdk-1.29.0/lib/aws/rails.rb:108:in `load_yaml_config'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/aws-sdk-1.29.0/lib/aws/rails.rb:54:in `setup'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/aws-sdk-1.29.0/lib/aws/rails.rb:26:in `block in <class:Railtie>'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/psycho/Desktop/filesdroid/config/environment.rb:5:in `<top (required)>'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `block in require'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
from /home/psycho/Desktop/filesdroid/config.ru:3:in `block in <main>'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from /home/psycho/Desktop/filesdroid/config.ru:in `new'
from /home/psycho/Desktop/filesdroid/config.ru:in `<main>'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.3/lib/rails/commands/server.rb:46:in `app'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.3/lib/rails/commands/server.rb:70:in `start'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.3/lib/rails/commands.rb:55:in `block in <top (required)>'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.3/lib/rails/commands.rb:50:in `tap'
from /home/psycho/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.3/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
它清楚地指向我environment.rb
的第5行。我已经检查过,那里什么都没有:
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
FilesDroid::Application.initialize! # Line 5
这只是一个初始化调用。如果我从gemfile中删除aws-sdk
,则不会发生这种情况。请帮帮忙?
答案 0 :(得分:2)
Psych
是一个yaml
解析器,看起来它正在尝试解析格式不正确的yaml
文件:
(<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 1 (Psych::SyntaxError)
我碰巧知道aws-sdk
gem尝试从config/aws.yml
读取aws凭据。你有一个文件,并且格式正确吗?