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

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

Open
stanhu opened this issue Apr 26, 2024 · 5 comments · Fixed by #7030
Open

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

stanhu opened this issue Apr 26, 2024 · 5 comments · Fixed by #7030

Comments

@stanhu
Copy link
Contributor

stanhu commented Apr 26, 2024

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.

stanhu added a commit to stanhu/inspec that referenced this issue Apr 26, 2024
parser 3.3.1.0 introduced
whitequark/parser#1000, which causes this
failure:

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

        include Parser::AST::Processor::Mixin
                                      ^^^^^^^
```

Fix this by inherting from `Parser::AST::Processor` and
requiring the right version of the `parser` gem.

Closes inspec#7029
stanhu added a commit to stanhu/inspec that referenced this issue Apr 26, 2024
parser 3.3.1.0 introduced
whitequark/parser#1000, which causes this
failure:

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

        include Parser::AST::Processor::Mixin
                                      ^^^^^^^
```

Fix this by inherting from `Parser::AST::Processor` and
requiring the right version of the `parser` gem.

Closes inspec#7029

Signed-off-by: Stan Hu <[email protected]>
stanhu added a commit to stanhu/inspec that referenced this issue Apr 30, 2024
parser 3.3.1.0 introduced
whitequark/parser#1000, which causes this
failure:

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

        include Parser::AST::Processor::Mixin
                                      ^^^^^^^
```

Fix this by inherting from `Parser::AST::Processor` instead.

Closes inspec#7029

Signed-off-by: Stan Hu <[email protected]>
stanhu added a commit to stanhu/inspec that referenced this issue Apr 30, 2024
parser 3.3.1.0 introduced
whitequark/parser#1000, which causes this
failure:

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

        include Parser::AST::Processor::Mixin
                                      ^^^^^^^
```

Fix this by inherting from `Parser::AST::Processor` instead.

Closes inspec#7029

Signed-off-by: Stan Hu <[email protected]>
ahasunos pushed a commit that referenced this issue May 2, 2024
parser 3.3.1.0 introduced
whitequark/parser#1000, which causes this
failure:

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

        include Parser::AST::Processor::Mixin
                                      ^^^^^^^
```

Fix this by inherting from `Parser::AST::Processor` instead.

Closes #7029

Signed-off-by: Stan Hu <[email protected]>
ahasunos pushed a commit that referenced this issue May 2, 2024
parser 3.3.1.0 introduced
whitequark/parser#1000, which causes this
failure:

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

        include Parser::AST::Processor::Mixin
                                      ^^^^^^^
```

Fix this by inherting from `Parser::AST::Processor` instead.

Closes #7029

Signed-off-by: Stan Hu <[email protected]>
@ahasunos
Copy link
Contributor

ahasunos commented May 2, 2024

Keeping it open till we release the version of InSpec with this change.

@ahasunos ahasunos reopened this May 2, 2024
ahasunos added a commit that referenced this issue May 2, 2024
parser 3.3.1.0 introduced
whitequark/parser#1000, which causes this
failure:

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

        include Parser::AST::Processor::Mixin
                                      ^^^^^^^
```

Fix this by inherting from `Parser::AST::Processor` instead.

Closes #7029

Signed-off-by: Stan Hu <[email protected]>
Co-authored-by: Stan Hu <[email protected]>
@stanhu
Copy link
Contributor Author

stanhu commented May 13, 2024

@ahasunos Is there a timeframe when we can expect a released update of InSpec? Otherwise I'll go ahead and apply the patch in #7030.

@Vasu1105
Copy link
Contributor

@stanhu we are planning the release in next week.

@stanhu
Copy link
Contributor Author

stanhu commented May 25, 2024

@Vasu1105 Thanks, I see from https://rubygems.org/gems/inspec that v5.22.50 was released to RubyGems. Could you release something for v6.6.0?

@Vasu1105
Copy link
Contributor

Yes, We are planning for that too. We will update you as soon as we release it. Thanks!!

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

Successfully merging a pull request may close this issue.

3 participants