简体   繁体   English

rails 4:在第 2 行第 11 列的上下文中不允许映射值(Psych::SyntaxError)?

[英]rails 4: mapping values are not allowed in this context at line 2 column 11 (Psych::SyntaxError)?

I have successfully installed rails 4 and created project using rails 4.0.0我已经成功安装了 rails 4 并使用 rails 4.0.0 创建了项目

rails s

for the first time was working fine.第一次工作正常。 But after adding 'devise' gem in gemfile但是在 gemfile 中添加“设计”gem 之后

 gem 'devise', '~> 3.0.0.rc'

and running bundle install, I am getting following error.并运行 bundle install,我收到以下错误。 What is the cause of this error and what will be the solution for it?这个错误的原因是什么,它的解决方案是什么?

I have tried with commenting gem 'devise' section also, but now i am getting same error for every rails command.我也尝试过评论 gem 'devise' 部分,但现在我对每个 rails 命令都遇到相同的错误。

/home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:205:in `parse':   (<unknown>): mapping values are not allowed in this context at line 2 column 11 (Psych::SyntaxError)
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:205:in `parse_stream'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:153:in `parse'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:129:in `load'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/config_file.rb:318:in `load_file'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/config_file.rb:191:in `initialize'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/gem_runner.rb:66:in `new'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/gem_runner.rb:66:in `do_configuration'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/gem_runner.rb:46:in `run'

database.yml file数据库.yml 文件

development:
adapter: mysql2
encoding: utf8
database: realstate_development
pool: 5
username: root
password: root
socket: /var/run/mysqld/mysqld.sock

gem 'devise' with any version, is showing following error on bundle, if I remove devise gem it works fine, I used rails 3.2.13 but I never faced such problem, what a strange.任何版本的 gem 'devise' 都会在 bundle 上显示以下错误,如果我删除了 devise gem 它工作正常,我使用了 rails 3.2.13 但我从未遇到过这样的问题,真是奇怪。

Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Unfortunately, a fatal error has occurred. Please see the Bundler troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
/home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:205:in `parse': (<unknown>): mapping values are not allowed in this context at line 2 column 11 (Psych::SyntaxError)
    from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:205:in `parse_stream'
    from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:153:in `parse'
    from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:129:in `load'
    from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/config_file.rb:318:in `load_file'
    from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/config_file.rb:191:in `initialize'
    from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems.rb:319:in `new'
    from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems.rb:319:in `configuration'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:34:in `configuration'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:53:in `sources='
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:250:in `remote_specs'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:163:in `fetch_specs'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:67:in `specs'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/definition.rb:192:in `block (2 levels) in index'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/definition.rb:189:in `each'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/definition.rb:189:in `block in index'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/index.rb:9:in `build'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/definition.rb:185:in `index'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/definition.rb:179:in `resolve'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/definition.rb:114:in `specs'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/definition.rb:109:in `resolve_remotely!'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/installer.rb:83:in `run'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/installer.rb:14:in `install'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/cli.rb:247:in `install'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/vendor/thor/task.rb:27:in `run'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_task'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/vendor/thor.rb:344:in `dispatch'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/vendor/thor/base.rb:434:in `start'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/bin/bundle:20:in `block in <top (required)>'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/friendly_errors.rb:3:in `with_friendly_errors'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/bin/bundle:20:in `<top (required)>'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/bin/bundle:23:in `load'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/bin/bundle:23:in `<main>'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval'
    from /home/siv/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `<main>'

If somebody still comes the same error you may to check the YAML files in your project.如果有人仍然出现相同的错误,您可以检查项目中的YAML文件。 In this example the problem is missed indentations in database.yml .在这个例子中,问题是在database.yml 中遗漏了缩进。 It should looks like this:它应该是这样的:

development:
  adapter: mysql2
  encoding: utf8
  database: realstate_development
  pool: 5
  username: root
  password: root
  socket: /var/run/mysqld/mysqld.sock

I get the same error but on other grounds, and the whole problem was in incorrect application.yml我得到了同样的错误,但出于其他原因,整个问题出在不正确的application.yml

First note the yml file in which parse method fails due to Psych::SyntaxError.首先注意 yml 文件,其中 parse 方法由于 Psych::SyntaxError 而失败。 Then look the file for the following然后在文件中查找以下内容

The YAML files should be properly indented and correct syntax must be followed. YAML 文件应该正确缩进,并且必须遵循正确的语法。
1.All members of a list are lines beginning at the same indentation level starting with a "- " (a dash and a space): 1.列表的所有成员都是以相同缩进级别开始的行,以“-”(破折号和空格)开头:
2.A dictionary is represented in a simple key: value form (the colon must be followed by a space): 2.字典以简单的键:值形式表示(冒号后必须跟一个空格):
For more syntax related information check the following link: http://docs.ansible.com/ansible/YAMLSyntax.html有关更多语法相关信息,请查看以下链接: http : //docs.ansible.com/ansible/YAMLSyntax.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 第2行第8行(Psych :: SyntaxError)不允许在此上下文中使用映射值 - mapping values are not allowed in this context at line 2 column 8 (Psych::SyntaxError) Mongodb / mongoid rails项目—“在解析第8行第7列的块映射时未找到预期的键(Psych :: SyntaxError)” - Mongodb/mongoid rails project — “did not find expected key while parsing a block mapping at line 8 column 7 (Psych::SyntaxError)” 〜/ ruby​​-2.1.1 / lib / ruby​​ / 2.1.0 / psych.rb:370:在`parse&#39;中:( <unknown> ):映射值是…在第3行第8列(Psych :: SyntaxError) - ~/ruby-2.1.1/lib/ruby/2.1.0/psych.rb:370:in `parse': (<unknown>): mapping values are … at line 3 column 8 (Psych::SyntaxError) 在gem安装或捆绑安装期间,“第1行第1列的控制字符不允许(Psych :: SyntaxError)” - “control characters are not allowed at line 1 column 1 (Psych::SyntaxError)” during gem install or bundle install cap deploy:migrations:错误:在第1行第1列中不允许使用控制字符(Psych :: SyntaxError) - cap deploy:migrations: Error: control characters are not allowed at line 1 column 1 (Psych::SyntaxError) 错误消息:Psych::SyntaxError: (<unknown> ): 在第 3 行第 1 列解析块映射时未找到预期的键</unknown> - Error Message: Psych::SyntaxError: (<unknown>): did not find expected key while parsing a block mapping at line 3 column 1 在此上下文中不允许使用Capistrano映射进行部署时出现psych.rb错误 - psych.rb error when deploying with Capistrano 'mapping not allowed in this context' 运行DelayedJob时,“在此上下文中,第xx行不允许映射值” - “mapping values are not allowed in this context at line xx” when running DelayedJob 使用JRuby的Rails应用无法正常工作-Psych :: SyntaxError:( <unknown> ) - Rails app with JRuby not working - Psych::SyntaxError: (<unknown>) (<unknown> ): 扫描第 3 行第 1 列的简单键时找不到预期的 &#39;:&#39; (Psych::SyntaxError) - (<unknown>): could not find expected ':' while scanning a simple key at line 3 column 1 (Psych::SyntaxError)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM