rails 4:在第2行第11列(Psych :: SyntaxError)的上下文中不允许映射值 [英] rails 4: mapping values are not allowed in this context at line 2 column 11 (Psych::SyntaxError)?
问题描述
我已成功安装rails 4并使用rails 4.0.0创建项目
rails s
第一次工作正常。但是在宝石文件中添加devisegem之后,您可以在
gem'devise','〜> 3.0.0.rc'
并运行包安装,我收到以下错误。这个错误的原因是什么?解决方案是什么?
我也尝试过评论宝石'devise'部分,但现在我得到相同的错误对于每个rails命令。
/home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby /2.0.0/psych.rb:205:in`parse':(< unknown>):在上下文中不允许在第2行第11列(Psych :: SyntaxError)
从/ home / siv / .rvm / rubies / ruby-2.0.0-p247 / lib / ruby / 2.0.0 / psych.rb:205:在`parse_stream'
from /home/siv/.rvm/rubies/ruby- 2.0.0-p247 / lib / ruby / 2.0.0 / psych.rb:153:在`parse'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby /2.0.0/psych.rb:129:in从/home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/config_file载入'
。 rb:318:在`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:在`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文件
开发:
适配器:mysql2
encoding:utf8
数据库:realstate_development
池:5
用户名:root
密码:root
套接字:/ var /在任何版本中运行/ mysqld / mysqld.sock
gem'devise',在bundle上显示以下错误,如果我删除devise宝石它工作正常,我使用rails 3.2.13,但我从来没有遇到这样的问题,什么奇怪。
获取宝石元数据从https://rubygems.org/ ..获取宝石元数据
不幸的是,一个致命的错误发生。请参阅Bundler疑难解答文档,网址为http://bit.ly/bundler-issues。谢谢!
/home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:205:in`parse':(< unknown>):映射值在这个上下文中不允许在/home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych的第2行第11列(Psych :: SyntaxError)
。 rb:205:在`parse_stream'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:153:in`parse'$来自/ home / siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:129:in的`
从/ home / siv / .rvm / rubies / ruby-2.0.0-p247 / lib / ruby / site_ruby / 2.0.0 / rubygems / config_file.rb:318:在`load_file'
from /home/siv/.rvm/rubies/ ruby-2.0.0-p247 / lib / ruby / site_ruby / 2.0.0 / rubygems / config_file.rb:191:在`initialize'
from /home/siv/.rvm/rubies/ruby-2.0.0 -p247 / lib / ruby / site_ruby / 2.0.0 / rubygems.rb:319:在`new'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/ site_ruby / 2.0.0 / rubygems.rb:319:在`配置'
从/home/siv/.rvm/gems/ruby-2.0.0-p247@global/gem s / bundler-1.3.5 / lib / bundler / rubygems_integration.rb:34:在`configuration'
from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler -1.3.5 / lib / bundler / rubygems_integration.rb:53:在`sources ='
from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3 .5 / lib / bundler / source / rubygems.rb:250:在`remote_specs'
from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3。 5 / lib / bundler / source / rubygems.rb:163:在`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:在`block(2级)'的索引'
从/home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3 .5 / lib / bundler / definition.rb:189:在each
from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/ lib / bundler / definition.rb:189:在`block in index'
from / home / siv / .rvm / gems / ruby-2.0.0-p247 @ global / gems / bundler-1.3.5 / lib / bundler / index.rb:9:在`build'
from /home/siv/.rvm/ gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/definition.rb:185:在index
from /home/siv/.rvm/gems/ruby -2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/definition.rb:179:在`resolve'
from /home/siv/.rvm/gems/ruby-2.0。 0-p247@global/gems/bundler-1.3.5/lib/bundler/definition.rb:114:在`specs'
from /home/siv/.rvm/gems/ruby-2.0.0-p247 @ global / gems / bundler-1.3.5 / lib / bundler / definition.rb:109:在`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:在`install'
from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3 .5 / lib / bundler / cli.rb:247:在`install'
from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3。 5 / lib / bundler / vendor / thor / task.rb:27:在`run'
from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3 .5 / lib / bundler / vendor / thor / invocation.rb:120:在`invoke_task'
from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler- 1.3.5 / lib / bundler / vendor / thor.rb:344:在`dispatch'
from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3 .5 / lib / bundler / vendor / thor / base.rb:434:在`start'
from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler- 1.3.5 / bin / bundle:20:在`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:在`with_friendly_errors'
from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3 .5 / bin / bundle:20:在`< top(required)>'
from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/bin/bundle:23 :在`load'
from /home/siv/.rvm/gems/ruby-2.0.0-p247@global/bin/bundle:23:in`< main>'
来自/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:在`< main>'
如果有人仍然出现同样的错误,您可以查看项目中的 YAML 文件。在这个例子中,问题是在 database.yml 中错过了缩进。它应该如下所示:
开发:
适配器:mysql2
encoding:utf8
数据库:realstate_development
池:5
用户名:root
密码:root
套接字:/var/run/mysqld/mysqld.sock
我得到相同的错误,但基于其他原因,整个问题是不正确的 application.yml
I have successfully installed rails 4 and created project using rails 4.0.0
rails s
for the first time was working fine. But after adding 'devise' gem in gemfile
gem 'devise', '~> 3.0.0.rc'
and running bundle install, I am getting following error. 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.
/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
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.
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. In this example the problem is missed indentations in 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
这篇关于rails 4:在第2行第11列(Psych :: SyntaxError)的上下文中不允许映射值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!