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

Potential Parser Breaking Change in Newest Version (2.2.2.5) #1934

Closed
pbrown-fiksu opened this issue Jun 1, 2015 · 24 comments
Closed

Potential Parser Breaking Change in Newest Version (2.2.2.5) #1934

pbrown-fiksu opened this issue Jun 1, 2015 · 24 comments

Comments

@pbrown-fiksu
Copy link

It looks like parser made a breaking change recently that is effecting Rubocop.

$ rubocop -V
warning: parser/current is loading parser/ruby21, which recognizes
warning: 2.1.6-compliant syntax, but you are running 2.1.5.
/Users/pbrown/.rvm/gems/ruby-2.1.5@fma-dev/gems/parser-2.2.2.5/lib/parser/ruby21.rb:13:in `<top (required)>': undefined method `check_for_encoding_support' for Parser:Module (NoMethodError)
    from /Users/pbrown/.rvm/gems/ruby-2.1.5@fma-dev/gems/parser-2.2.2.5/lib/parser/current.rb:36:in `require'
    from /Users/pbrown/.rvm/gems/ruby-2.1.5@fma-dev/gems/parser-2.2.2.5/lib/parser/current.rb:36:in `<module:Parser>'
    from /Users/pbrown/.rvm/gems/ruby-2.1.5@fma-dev/gems/parser-2.2.2.5/lib/parser/current.rb:1:in `<top (required)>'
    from /Users/pbrown/.rvm/gems/ruby-2.1.5@fma-dev/gems/rubocop-0.31.0/lib/rubocop.rb:3:in `require'
    from /Users/pbrown/.rvm/gems/ruby-2.1.5@fma-dev/gems/rubocop-0.31.0/lib/rubocop.rb:3:in `<top (required)>'
    from /Users/pbrown/.rvm/gems/ruby-2.1.5@fma-dev/gems/rubocop-0.31.0/bin/rubocop:6:in `require'
    from /Users/pbrown/.rvm/gems/ruby-2.1.5@fma-dev/gems/rubocop-0.31.0/bin/rubocop:6:in `<top (required)>'
    from /Users/pbrown/.rvm/gems/ruby-2.1.5@fma-dev/bin/rubocop:23:in `load'
    from /Users/pbrown/.rvm/gems/ruby-2.1.5@fma-dev/bin/rubocop:23:in `<main>'
    from /Users/pbrown/.rvm/gems/ruby-2.1.5@fma-dev/bin/ruby_executable_hooks:15:in `eval'
    from /Users/pbrown/.rvm/gems/ruby-2.1.5@fma-dev/bin/ruby_executable_hooks:15:in `<main>'
@bbatsov
Copy link
Collaborator

bbatsov commented Jun 1, 2015

/cc @whitequark

@whitequark
Copy link

Er, no. That function is defined in lib/parser.rb, and lib/parser/ruby21.rb starts like:

require 'parser'
Parser.check_for_encoding_support

Something is wrong with your install.

@pbrown-fiksu
Copy link
Author

This has been experienced by 2 other people in my office, and we’ve all destroyed our gemsets and rebuilt to confirm.

Is there any information I can provide to help debug?

@whitequark
Copy link

Then some other gem defines a lib/parser.rb file. Try looking in $LOADED_FEATURES after require 'parser'.

@pbrown-fiksu
Copy link
Author

Ah! That was it!

pry(main)> ap $LOADED_FEATURES.select{ |n| /lib\/parser.rb/.match(n) }
[
    [0] "/Users/pbrown/.rvm/gems/ruby-2.1.5@fma-dev/gems/ruby-imagespec-0.3.1/lib/parser.rb"
]

Thanks :)

@bbatsov bbatsov closed this as completed Jun 6, 2015
@xacaxulu
Copy link

+1 Had to downgrade to 0.31 to solve this.

@typeoneerror
Copy link

Same issue here. Anyone have an idea how to remedy this?

pry(main)> $LOADED_FEATURES.select{ |n| /lib\/parser.rb/.match(n) }
=> ["/Users/typeoneerror/.rvm/gems/ruby-2.1.5@doki/gems/parser-2.3.0.pre.2/lib/parser.rb"]

@whitequark
Copy link

@typeoneerror What is the exact error you're getting?

@typeoneerror
Copy link

@whitequark

$ rubocop -v
warning: parser/current is loading parser/ruby21, which recognizes
warning: 2.1.7-compliant syntax, but you are running 2.1.5.
0.32.1

@typeoneerror
Copy link

Just curious if this warning is safe to ignore and if I can silence it if so?

@whitequark
Copy link

See https://github.com/whitequark/parser#compatibility-with-ruby-mri for why it exists. You can silence it with ruby -W0 -S rubocop, or by upgrading your Ruby

@typeoneerror
Copy link

@whitequark thanks, that makes sense. and thank you for the silencer 👍

@typeoneerror
Copy link

I guess I don't understand this. Seems to be one version ahead no matter what I try?

warning: parser/current is loading parser/ruby22, which recognizes
warning: 2.2.3-compliant syntax, but you are running 2.2.2.
0.32.1

@whitequark
Copy link

Why are you using parser from git?

@whitequark
Copy link

Or, well, pre-release, which is more or less same thing

@typeoneerror
Copy link

Honestly don't know. I just installed ruby 2.2.2 via rvm.

@whitequark
Copy link

How did you install parser?

@typeoneerror
Copy link

It was installed as a dependency of rubocop, as far as I can tell.

rubocop (0.32.1)
      astrolabe (~> 1.3)
      parser (>= 2.2.2.5, < 3.0)
      powerpack (~> 0.1)
      rainbow (>= 1.99.1, < 3.0)
      ruby-progressbar (~> 1.4)

Never explicitly installed it to my recollection and can't find it on my system outside of the gemset that rubocop was installed to. Puzzling!

@whitequark
Copy link

Hm, so what's the exact parser version that got selected? This is odd.

@typeoneerror
Copy link

Just deleted my gemset, recreated and did a fresh bundle install. Gemfile.lock is showing:

parser (2.3.0.pre.2)

and

astrolabe (1.3.0)
  parser (>= 2.2.0.pre.3, < 3.0)

Whole thing here.

@whitequark
Copy link

@yujinakayama Filed a big here yujinakayama/astrolabe#3

@typeoneerror
Copy link

Great, appreciate your time looking into this. Thanks!

@asaaki
Copy link

asaaki commented Aug 10, 2015

If you still have the issue, this worked for me:

gem install parser # should install the current stable, not pre (currently 2.2.2.6)
gem uninstall parser -v=2.3.0.pre.2

In a Gemfile you might need to add parser gem with desired version (gem 'parser', '~> 2.2.2.6').

I wonder why the pre version is installed anyway (I thought one would have to explicitly opt-in for that).

@gjtorikian
Copy link

@asaaki Thanks! Your instructions worked for me. 🤘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants