Ruby 2.2.1 did not contain rubocop.checker ruby/rubocop:can't parse version string (abnormal termination?)

Asked 1 years ago, Updated 1 years ago, 61 views

I would like to use rubocop on my Mac (Yosemite).

$rubocop<filename>

Then you can do a syntax check.

However, the problem is that the syntax check after saving is not possible in vim.

Below is the work history.

=======================================================

I added rubocop to vimrc by referring to the article below.
http://qiita.com/yuku_t/items/0ac33cea18e10f14e185

r It is done under ruby 2.2.1 environment.For some reason, ruby is fixed with this version.

NeoBundle'scroolose/syntastic'
letg:syntastic_mode_map = {'mode': 'passive',
            \ 'active_filetypes': ['ruby']}
letg:syntastic_ruby_checkers=['rubocop']

However, I received the following error:

symmetric:error:checker output:
warning —you are loading parser/ruby22 from ~/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubyge
ms/core_ext/kernel_require.rb: 69:in `require'.
warning —Ruby 2.2 is not released yet and parser support may be incomplete.
0.26.1
symmetric:error:checker ruby/rubocop:can't parse version string (abnormal termination?)

Therefore, I dropped the version by referring to the article below.
http://qiita.com/ka2n/items/55a435c10a240ea5d434

parser —2.2.0.pre.5
Rubocop:0.26.1

However, I still received the following error and could not find out any more.

warning: parser/current is loading parser/ruby22, which recognizes
warning: 2.2.3-component syntax, but you are running 2.2.1.
warning —Please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
0.35.1

When I looked into it, I saw an article saying rubocop would not work unless it was the latest version.
Does it mean that 2.2.1 won't work?

Thank you for your cooperation.

ruby-on-rails ruby rubygems

2022-09-30 18:06

1 Answers

Based on the Qiita article, I looked up the version of parsergem (rubocop dependent gem) that works without causing any errors.
Ruby 2.2.1 and Rubocop seem to have corresponding parsergem version 2.2.0.1

  • bundle init and described in rubocop (no version specified), parser (with version specified)
  • Open the appropriate .rb file in vim and save it.Verified operation.
  • If you get an error, do gem uninstall rubocop parserast;gem cleanup; and lower the versioning of the parsergem to bundle update

Now you can create a combination of gems that work without bundle exec.

Gemfile:

source 'https://rubygems.org'

gem 'rubocop'
gem 'parser', '2.2.0.1'

The relationship between the versions recorded in Gemfile.lock is as follows:

GEM
  remote —https://rubygems.org/
  specifics:
    as (2.1.0)
    astrolabe (1.3.1)
      parser (~>2.2)
    parser (2.2.0.1)
      ast(>=1.1, <3.0)
      US>slop (~>3.4, >=3.4.5)
    powerpack (0.1.1)
    rainbow (2.0.0)
    rubocop (0.30.0)
      astrolabe (~>1.3)
      parser(>=2.2.0.1, <3.0)
      powerpack (~>0.1)
      rainbow(>=1.99.1, <3.0)
      ruby-progressbar (~>1.4)
    ruby-progressbar (1.7.5)
    US>slop (3.6.0)

PLATFORMS
  ruby

DEPENDENCIES
  parser(=2.2.0.1)
  rubocop

BUNDLED WITH
   1.10.6


2022-09-30 18:06

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.