第2行第8行(Psych :: SyntaxError)不允许在此上下文中使用映射值

时间:2015-01-02 13:42:26

标签: ruby-on-rails ruby ruby-on-rails-4

我正在通过Ruby on Rails教程(Michael Hartl)学习RoR。

当我添加到.gemrc

sublime ~/.gemrc

(已安装Sublime Text),我只是检查,例如

gem -v

我得到了

Failed to load /home/gvyntyk/.gemrc because it doesn't contain valid YAML hash

顺便说一句:

gvyntyk@gvyntyk-r60:~$ ldconfig -p | grep libyaml
libyaml-0.so.2 (libc6) => /usr/lib/i386-linux-gnu/libyaml-0.so.2

当我添加.gemrc行时:

install: --no-rdoc --no-ri
update:  --no-rdoc --no-ri

(当然,我不想安装文档)

我收到错误:

gvyntyk@gvyntyk-r60:~$ gem install rails --version 4.0.2
/home/gvyntyk/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/psych.rb:205:in `parse': (<unknown>): mapping values are not allowed in this context at line 2 column 8 (Psych::SyntaxError)
    from /home/gvyntyk/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/psych.rb:205:in `parse_stream'
    from /home/gvyntyk/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/psych.rb:153:in `parse'
    from /home/gvyntyk/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/psych.rb:129:in `load'
    from /home/gvyntyk/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/config_file.rb:332:in `load_file'
    from /home/gvyntyk/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/config_file.rb:197:in `initialize'
    from /home/gvyntyk/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/gem_runner.rb:74:in `new'
    from /home/gvyntyk/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/gem_runner.rb:74:in `do_configuration'
    from /home/gvyntyk/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/gem_runner.rb:39:in `run'
    from /home/gvyntyk/.rvm/rubies/ruby-2.0.0-p598/bin/gem:21:in `<main>'

当我删除.gemrc时,我没有那些麻烦,我可以安装Rails。

怎么了?

Ubuntu 14.04.1 LTS

1 个答案:

答案 0 :(得分:0)

总结前面的所有评论,我也遇到了这个问题,它是.yml的语法问题,因此我建议您在任何yaml检查网页中检查您的代码,或尝试使用它并看看有什么解决您的问题。

就我而言,我的错误出在我的sidekiq.yml中:

:verbose: true
  :concurrency: 25
  :queues:
    - [mailers, 7]
    - [default, 5]

解决方案:

:concurrency: 25
:queues:
  - [mailers, 7]
  - [default, 5]

通过免费的heroku计划,您应该使用:

:concurrency: 1
:queues:
  - [mailers, 7]
  - [default, 5]

发现Heroku发出许多警报后,无论如何都会度过美好的一天!