Skip to content
New issue

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

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

Already on GitHub? # to your account

InSpec breaks with ActiveSupport 7.1.0 #750

Open
evandam opened this issue Oct 10, 2023 · 4 comments
Open

InSpec breaks with ActiveSupport 7.1.0 #750

evandam opened this issue Oct 10, 2023 · 4 comments

Comments

@evandam
Copy link

evandam commented Oct 10, 2023

Version:

Train 3.10.8

Environment:

MacOS Sonoma, InSpec 5.22.3, Ruby 3.1.4

InSpec installed and managed via Bundler:

# frozen_string_literal: true

source "https://rubygems.org"

gem "inspec-bin", "~> 5.22.0"

Scenario:

Run a basic profile. I'm seeing the issue against a Kubernetes target, but I don't believe the issue is specific to train-kubernetes, but rather the version of ActiveSupport that Train is using.

I believe it can be resolved by tweaking the dependency version to something like ~> 7.0.0 instead of >= 6.0.3.1. There's some discussion in inspec/inspec#6527

Steps to Reproduce:

Use the Gemfile mentioned above, and a similar inspec.yml for a profile:

name: kubernetes
title: InSpec Profile
maintainer: The Authors
copyright: The Authors
copyright_email: you@example.com
license: Apache-2.0
summary: An InSpec Compliance Profile
version: 0.1.0
inspec_version: "~> 5.22"
supports:
  platform: k8s
depends:
  - name: inspec-k8s
    git: https://github.com/inspec/inspec-k8s
    branch: main

Run InSpec:

bundle install
bundle exec inspec exec ./kubernetes -t k8s://

Expected Result:

InSpec runs as expected.

Profile:   InSpec Profile (kubernetes)
Version:   0.1.0
Target:    kubernetes://6847289D2FB4BC9AC036293B0EA62ABC.gr7.us-west-2.eks.amazonaws.com:443
Target ID: 15f2b11e-28d1-5111-82f6-1ef5f5095c4c

     No tests executed.

Profile:   InSpec Profile (inspec-k8s)
Version:   0.1.3
Target:    kubernetes://6847289D2FB4BC9AC036293B0EA62ABC.gr7.us-west-2.eks.amazonaws.com:443
Target ID: 15f2b11e-28d1-5111-82f6-1ef5f5095c4c

     No tests executed.

Test Summary: 0 successful, 0 failures, 0 skipped

Actual Result:

/Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.1.0/lib/active_support/core_ext/array/conversions.rb:108:in `<class:Array>': undefined method `deprecator' for ActiveSupport:Module (NoMethodError)

  deprecate to_default_s: :to_s, deprecator: ActiveSupport.deprecator
                                                          ^^^^^^^^^^^
Did you mean?  deprecate_constant
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.1.0/lib/active_support/core_ext/array/conversions.rb:8:in `<top (required)>'
	from <internal:/Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.1.0/lib/active_support/duration.rb:3:in `<top (required)>'
	from <internal:/Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.1.0/lib/active_support/core_ext/time/calculations.rb:3:in `<top (required)>'
	from <internal:/Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.1.0/lib/active_support/core_ext/string/conversions.rb:4:in `<top (required)>'
	from <internal:/Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.1.0/lib/active_support/core_ext/string.rb:3:in `<top (required)>'
	from <internal:/Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/inspec-core-5.22.3/lib/inspec/dsl_shared.rb:33:in `require'
	from libraries/k8sobjects.rb:4:in `create'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/inspec-core-5.22.3/lib/inspec/dsl_shared.rb:47:in `eval'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/inspec-core-5.22.3/lib/inspec/dsl_shared.rb:47:in `require'
	from libraries/k8s_api_resources.rb:3:in `load_with_context'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/inspec-core-5.22.3/lib/inspec/profile_context.rb:171:in `instance_eval'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/inspec-core-5.22.3/lib/inspec/profile_context.rb:171:in `load_with_context'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/inspec-core-5.22.3/lib/inspec/profile_context.rb:160:in `load_library_file'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/inspec-core-5.22.3/lib/inspec/profile_context.rb:145:in `block in load_libraries'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/inspec-core-5.22.3/lib/inspec/profile_context.rb:144:in `each'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/inspec-core-5.22.3/lib/inspec/profile_context.rb:144:in `load_libraries'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/inspec-core-5.22.3/lib/inspec/profile.rb:381:in `load_libraries'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/inspec-core-5.22.3/lib/inspec/profile.rb:374:in `block in load_libraries'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/inspec-core-5.22.3/lib/inspec/profile.rb:353:in `each'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/inspec-core-5.22.3/lib/inspec/profile.rb:353:in `each_with_index'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/inspec-core-5.22.3/lib/inspec/profile.rb:353:in `load_libraries'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/inspec-core-5.22.3/lib/inspec/runner.rb:111:in `block in load'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/inspec-core-5.22.3/lib/inspec/runner.rb:104:in `each'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/inspec-core-5.22.3/lib/inspec/runner.rb:104:in `load'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/inspec-core-5.22.3/lib/inspec/runner.rb:163:in `run'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/inspec-core-5.22.3/lib/inspec/cli.rb:364:in `exec'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor/command.rb:27:in `run'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor.rb:392:in `dispatch'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor/base.rb:485:in `start'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/inspec-core-5.22.3/lib/inspec/base_cli.rb:35:in `start'
	from /Users/evan/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/inspec-bin-5.22.3/bin/inspec:11:in `<top (required)>'
	from /Users/evan/.asdf/installs/ruby/3.1.4/bin/inspec:25:in `load'
	from /Users/evan/.asdf/installs/ruby/3.1.4/bin/inspec:25:in `<main>'
@Schwad
Copy link

Schwad commented Oct 11, 2023

There is a larger discussion around this here on rails/rails: rails/rails#49495 (comment)

There is a related cocoapods issue, so there may be learnings to be gathered here: CocoaPods/CocoaPods#12082

e.g. ensure requires are happening for activesupport when used outside of rails ecosystem

@Schwad
Copy link

Schwad commented Oct 11, 2023

Ah, I lost my contributor badge! 😔 Maybe it's because my old Chef work email is no longer tied to this account or something

@ahasunos
Copy link
Contributor

@Schwad @evandam
inspec/inspec-k8s#37

@Schwad
Copy link

Schwad commented Oct 12, 2023

@ahasunos nice!

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

Successfully merging a pull request may close this issue.

3 participants