简体   繁体   English

(<unknown> ): 扫描第 3 行第 1 列的简单键时找不到预期的 &#39;:&#39; (Psych::SyntaxError)

[英](<unknown>): could not find expected ':' while scanning a simple key at line 3 column 1 (Psych::SyntaxError)

I am trying to run a bundle install on a rails project pulled from git.我正在尝试在从 git 中提取的 rails 项目上运行捆绑安装。 When I run the bundle install I get the following error:当我运行 bundle install 时,出现以下错误:

    /Users/jordandeutsch/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/psych.rb:370:in     `parse': (<unknown>): could not find expected ':' while scanning a simple key at     line 3 column 1 (Psych::SyntaxError)
    from /Users/jordandeutsch/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/psych.rb:370:in `parse_stream'
    from /Users/jordandeutsch/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/psych.rb:318:in `parse'
    from /Users/jordandeutsch/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/psych.rb:245:in `load'
    from /Users/jordandeutsch/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/config_file.rb:333:in `load_file'
    from /Users/jordandeutsch/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/config_file.rb:198:in `initialize'
    from /Users/jordandeutsch/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/gem_runner.rb:74:in `new'
    from /Users/jordandeutsch/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/gem_runner.rb:74:in `do_configuration'
    from /Users/jordandeutsch/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/gem_runner.rb:39:in `run'
    from /Users/jordandeutsch/.rvm/rubies/ruby-2.2.1/bin/gem:21:in `<main>'

This is my Gemfile:这是我的 Gemfile:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'

#for Authentification
gem 'devise'

#for image management
gem 'paperclip', :git => 'git://github.com/thoughtbot/paperclip.git'
gem 'aws-sdk-v1'
gem 'aws-s3'

group :development do
    gem 'better_errors'
end

group :development, :test do
    gem 'dotenv-rails'
end
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more:     https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger     console
  gem 'byebug'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the      background. Read more: https://github.com/rails/spring
  gem 'spring'
end

After some digging I thought it might be an issue with rvm as I tried pulling an old project off git and was still unable to run the bundle install.经过一番挖掘,我认为这可能是 rvm 的问题,因为我尝试从 git 中拉出一个旧项目,但仍然无法运行捆绑安装。 I also tried copying a project locally and running the install and starting a new project all without success.我还尝试在本地复制一个项目并运行安装并启动一个新项目,但都没有成功。

After reinstalling rvm I ran rvm use ruby --install --default and got the following error (similar to above)重新安装 rvm 后,我运行rvm use ruby --install --default并得到以下错误(类似于上面)

/Users/jordandeutsch/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/psych.rb:370:in `parse': (<unknown>): could not find expected ':' while scanning a simple key at line 3 column 1 (Psych::SyntaxError)
from /Users/jordandeutsch/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/psych.rb:370:in `parse_stream'
from /Users/jordandeutsch/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/psych.rb:318:in `parse'
from /Users/jordandeutsch/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/psych.rb:245:in `load'
from /Users/jordandeutsch/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/config_file.rb:333:in `load_file'
from /Users/jordandeutsch/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/config_file.rb:198:in `initialize'
from /Users/jordandeutsch/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/gem_runner.rb:74:in `new'
from /Users/jordandeutsch/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/gem_runner.rb:74:in `do_configuration'
from /Users/jordandeutsch/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/gem_runner.rb:39:in `run'
from /Users/jordandeutsch/.rvm/rubies/ruby-2.2.3/bin/gem:25:in `<main>'

Essentially I cannot begin a new rails project on the computer.基本上我无法在计算机上开始一个新的 Rails 项目。 Any insight would be appreciated.任何见解将不胜感激。

This error usually comes out if you have syntax errors in the .yml files. 如果.yml文件中存在语法错误,通常会出现此错误。 Have a look if you can find any mistake in there. 看看你是否能在那里发现任何错误。

You can also try and remove the .gemrc file from the home directory. 您也可以尝试从主目录中删除.gemrc文件。 It could be that the error is in there. 可能是错误就在那里。

I had this issue recently had this issue. 我最近遇到过这个问题。 My issue: 我的问题:

.application.yml .application.yml

default: &default
 FOO_KEY: 'XXXXX'

development:
  <<: *default

test:
  <<: *default

Worked fine. 工作得很好。

default: &default
  FOO_KEY: 'asdf'
  BAR_KEY: 'XXXXXXXXXXX'
  FOO_BAR: 'XXXXXXXXXXXX'

development:
  <<: *default

test:
  <<: *default

Did not work. 不工作。 What I tried: 我尝试了什么:

  • Rewrite application.yml 重写application.yml
  • Remove GEMFILE.lock and reinstall all gems 删除GEMFILE.lock并重新安装所有宝石
  • change the values and names of keys 更改键的值和名称
  • check all configs for typos 检查所有配置错误的拼写错误

None of these helped fix the issue. 这些都没有帮助解决问题。 So as any good engineer I burned it to the ground. 因此,作为一名优秀的工程师,我把它烧成了地面。 I cloned my project into a new directory and rewrote the application.yml and that worked. 我将我的项目克隆到一个新目录并重新编写application.yml,这很有用。 Both repos are on the same branch and on the same changeset. 两个repos都在同一个分支上,并且在同一个变更集上。

In case you still are looking for answers (after patching up your database.yml several times), try to check other yml files that are loaded upon initialization of the application, like secrets.yml , sidekiq.yml , webpacker.yml or so. 如果你仍然在寻找答案(修补你的database.yml几次之后),尝试检查其他yml所于应用的初始化加载,如文件secrets.ymlsidekiq.ymlwebpacker.yml左右。

In my case, it was throwing error like: 在我的情况下,它抛出的错误如下:

/home/abhishek/.rvm/gems/ruby-2.3.7/gems/railties-4.2.10/lib/rails/application/configuration.rb:115:in `rescue in database_configuration': YAML syntax error occurred while parsing /home/abhishek/Workspace/clearfunds/clearfunds-web/config/database.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Error: (<unknown>): could not find expected ':' while scanning a simple key at line 19 column 7 (RuntimeError)

But database.yml was intact. 但是database.yml完好无损。 The problem was in secrets.yml . 问题出在secrets.yml Had used tab indentation in a couple of places. 曾在几个地方使用过tab缩进。

For others who get this error, I got this error and it turned out there was non visible unicode characters that were creating conflicts.对于其他收到此错误的人,我收到了此错误,结果发现是不可见的 unicode 字符造成了冲突。 I found a website that shows where these characters are: https://www.soscisurvey.de/tools/view-chars.php我找到了一个显示这些字符在哪里的网站: https : //www.soscisurvey.de/tools/view-chars.php

暂无
暂无

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

相关问题 红宝石/红宝石-2.0.0-p0 / lib /红宝石/2.0.0/psych.rb:205:在&#39;parse&#39;中:( <unknown> ):在第18行第3列扫描简单密钥时找不到预期的&#39;:&#39; - 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: (<unknown> ): 在第 3 行第 1 列解析块映射时未找到预期的键</unknown> - Error Message: Psych::SyntaxError: (<unknown>): did not find expected key while parsing a block mapping at line 3 column 1 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)” 心理错误:“解析” :( <unknown> ):找不到预期 - Psych Error: `parse': (<unknown>): could not find expected 〜/ 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) rails 4:在第 2 行第 11 列的上下文中不允许映射值(Psych::SyntaxError)? - rails 4: mapping values are not allowed in this context at line 2 column 11 (Psych::SyntaxError)? 第2行第8行(Psych :: SyntaxError)不允许在此上下文中使用映射值 - mapping values are not allowed in this context at line 2 column 8 (Psych::SyntaxError) 使用JRuby的Rails应用无法正常工作-Psych :: SyntaxError:( <unknown> ) - Rails app with JRuby not working - Psych::SyntaxError: (<unknown>) ( <unknown> ):在运行rake db:migrate时在第18行第14列解析流节点时,未找到预期的节点内容 - (<unknown>): did not find expected node content while parsing a flow node at line 18 column 14 while running rake db:migrate 在gem安装或捆绑安装期间,“第1行第1列的控制字符不允许(Psych :: SyntaxError)” - “control characters are not allowed at line 1 column 1 (Psych::SyntaxError)” during gem install or bundle install
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM