Skip to content

uninitialized constant Parser::AST::Processor::Mixin with parser 3.3.1.0 #7029

@stanhu

Description

@stanhu

Describe the problem

parser 3.3.1.0 introduced whitequark/parser#1000, which causes this failure:

% bundle exec ruby -Itest test/unit/profiles/profile_test.rb
/Users/stanhu/github/inspec/lib/inspec/utils/profile_ast_helpers.rb:7:in `<class:CollectorBase>': uninitialized constant Parser::AST::Processor::Mixin (NameError)

        include Parser::AST::Processor::Mixin
                                      ^^^^^^^
Did you mean?  Mixlib
	from /Users/stanhu/github/inspec/lib/inspec/utils/profile_ast_helpers.rb:6:in `<class:AstHelper>'
	from /Users/stanhu/github/inspec/lib/inspec/utils/profile_ast_helpers.rb:5:in `<class:Profile>'
	from /Users/stanhu/github/inspec/lib/inspec/utils/profile_ast_helpers.rb:4:in `<module:Inspec>'
	from /Users/stanhu/github/inspec/lib/inspec/utils/profile_ast_helpers.rb:3:in `<top (required)>'
	from <internal:/Users/stanhu/.asdf/installs/ruby/3.2.3/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
	from <internal:/Users/stanhu/.asdf/installs/ruby/3.2.3/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
	from /Users/stanhu/github/inspec/lib/inspec/profile.rb:18:in `<top (required)>'
	from <internal:/Users/stanhu/.asdf/installs/ruby/3.2.3/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
	from <internal:/Users/stanhu/.asdf/installs/ruby/3.2.3/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
	from test/unit/profiles/profile_test.rb:6:in `<main>'

Possible Solution

diff --git a/inspec.gemspec b/inspec.gemspec
index 4ff761e48..83c4526a9 100644
--- a/inspec.gemspec
+++ b/inspec.gemspec
@@ -54,5 +54,5 @@ Source code obtained from the Chef GitHub repository is made available under Apa
   spec.add_dependency "train-kubernetes", "~> 0.1"
 
   spec.add_dependency "mongo", "= 2.13.2" # 2.14 introduces a broken symlink in mongo-2.14.0/spec/support/ocsp
-
+  spec.add_dependency "parser", ">= 3.3.1.0" # 3.3.1.0 removed a mix-in: https://github.com/whitequark/parser/pull/1000
 end
diff --git a/lib/inspec/utils/profile_ast_helpers.rb b/lib/inspec/utils/profile_ast_helpers.rb
index 8e00206f8..299e85bd5 100644
--- a/lib/inspec/utils/profile_ast_helpers.rb
+++ b/lib/inspec/utils/profile_ast_helpers.rb
@@ -3,8 +3,7 @@ require "rubocop-ast"
 module Inspec
   class Profile
     class AstHelper
-      class CollectorBase
-        include Parser::AST::Processor::Mixin
+      class CollectorBase < Parser::AST::Processor
         include RuboCop::AST::Traversal
 
         attr_reader :memo

The dependency graph:

inspec-core -> rubocop-ast -> parser >= 3.3.0.4

When parser 3.3.1.0 was released today, the previous mix-in no longer exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions