Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

could not find expected ':' while scanning a simple key at line 34 column 3 (Psych::SyntaxError) #10921

Closed
AlexWayfer opened this issue Aug 13, 2022 · 2 comments · Fixed by #10922
Labels

Comments

@AlexWayfer
Copy link
Contributor

Expected behavior

No errors.

Actual behavior

> bundle exec rubocop --debug
bundler: failed to load command: rubocop (/home/alex/.rbenv/versions/3.1.2/bin/rubocop)
/home/alex/.rbenv/versions/3.1.2/lib/ruby/3.1.0/psych.rb:455:in `parse': (/home/alex/Projects/ruby/alt_memery/.rubocop.yml): could not find expected ':' while scanning a simple key at line 34 column 3 (Psych::SyntaxError)
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/3.1.0/psych.rb:455:in `parse_stream'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/3.1.0/psych.rb:399:in `parse'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/3.1.0/psych.rb:324:in `safe_load'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/3.1.0/psych.rb:660:in `block in safe_load_file'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/3.1.0/psych.rb:659:in `open'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/3.1.0/psych.rb:659:in `safe_load_file'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rubocop-1.35.0/lib/rubocop/server/cache.rb:70:in `block in cache_root_dir_from_config'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rubocop-1.35.0/lib/rubocop/cache_config.rb:9:in `root_dir'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rubocop-1.35.0/lib/rubocop/server/cache.rb:61:in `cache_root_dir_from_config'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rubocop-1.35.0/lib/rubocop/server/cache.rb:54:in `cache_path'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rubocop-1.35.0/lib/rubocop/server/cache.rb:45:in `dir'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rubocop-1.35.0/lib/rubocop/server.rb:36:in `running?'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rubocop-1.35.0/exe/rubocop:11:in `<top (required)>'
	from /home/alex/.rbenv/versions/3.1.2/bin/rubocop:25:in `load'
	from /home/alex/.rbenv/versions/3.1.2/bin/rubocop:25:in `<top (required)>'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.20/lib/bundler/cli/exec.rb:58:in `load'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.20/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.20/lib/bundler/cli/exec.rb:23:in `run'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.20/lib/bundler/cli.rb:485:in `exec'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.20/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.20/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.20/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.20/lib/bundler/cli.rb:31:in `dispatch'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.20/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.20/lib/bundler/cli.rb:25:in `start'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.20/exe/bundle:48:in `block in <top (required)>'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.20/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
	from /home/alex/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.20/exe/bundle:36:in `<top (required)>'
	from /home/alex/.rbenv/versions/3.1.2/bin/bundle:25:in `load'
	from /home/alex/.rbenv/versions/3.1.2/bin/bundle:25:in `<main>'

Steps to reproduce the problem

require:
  - rubocop-performance
  - rubocop-rspec

inherit_mode:
  merge:
    - Include
    - Exclude

Layout/MultilineOperationIndentation:
  EnforcedStyle: indented
Layout/ArgumentAlignment:
  EnforcedStyle: with_fixed_indentation
Layout/LineLength:
  Max: 100

Metrics/BlockLength:
  Exclude:
    - '*.gemspec'
    - spec/**/*

Metrics/MethodLength:
  Exclude:
    - spec/**/*

Metrics/AbcSize:
  Exclude:
    - spec/**/*

AllCops:
  TargetRubyVersion: 2.7
  NewCops: enable
  Exclude:
  <% `git status --ignored --porcelain`.lines.grep(/^!! /).each do |path| %>
    - <%= path.sub(/^!! /, '') %>
  <% end %>

RSpec/MultipleMemoizedHelpers:
  Enabled: false
RSpec/NestedGroups:
  Enabled: false

RuboCop version

Failed, but it's:

ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]

And RuboCop updating from 1.32 to 1.35: https://github.com/AlexWayfer/alt_memery/pull/57/files

@dvandersluis
Copy link
Member

What does git status --ignored --porcelain return? (If you don't want to share it on github take a look at it). That seems to be line 34 so something in that line is not being parsed by YAML properly.

@AlexWayfer
Copy link
Contributor Author

What does git status --ignored --porcelain return?

!! .benchmark.rb
!! .test.rb
!! Gemfile.lock
!! coverage/
!! node_modules/
!! package-lock.json
!! pkg/
!! yarn.lock

If you don't want to share it on github take a look at it

As you can see, it's completely open-source project.

What does git status --ignored --porcelain return? (If you don't want to share it on github take a look at it). That seems to be line 34 so something in that line is not being parsed by YAML properly.

Yep, it seems like ERB. Supported by RuboCop. But, I guess, something got broken with Ruby 3.1 and Psych 4.0, where parsing became more strict.

@koic koic added the bug label Aug 15, 2022
koic added a commit to koic/rubocop that referenced this issue Aug 15, 2022
Fixes rubocop#10921.

This PR fixes an error when ERB pre-processing of the configuration file.
bbatsov pushed a commit that referenced this issue Aug 19, 2022
Fixes #10921.

This PR fixes an error when ERB pre-processing of the configuration file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants