Skip to content

Declare logger as a runtime dependency - #135

Merged
tpowell-progress merged 1 commit into
chef:mainfrom
tas50:fix/declare-logger-dependency
Sep 4, 2026
Merged

Declare logger as a runtime dependency#135
tpowell-progress merged 1 commit into
chef:mainfrom
tas50:fix/declare-logger-dependency

Conversation

@tas50

@tas50 tas50 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Description

lib/license_acceptance/config.rb requires logger, and Config#initialize calls ::Logger.new(IO::NULL) on the default path:

@logger = opts.fetch(:logger, ::Logger.new(IO::NULL))

So logger is a runtime dependency in practice. It was never declared, which was harmless while logger was a default gem.

Ruby 4.0 moved logger from a default gem to a bundled gem:

Gem::BUNDLED_GEMS::SINCE["logger"]                                 # => "4.0.0"
Gem::Specification.find_all_by_name("logger").first.default_gem?   # => false

Bundled gems ship with Ruby but are not on the load path of a bundle that doesn't ask for them. Under Ruby 4.0 the gem therefore fails to load at all:

result
before LoadError: cannot load such file -- logger — 0 examples, 1 error outside of examples
after 124 examples, 0 failures

Scope

logger is the only require in lib/ this affects. I cross-referenced every stdlib require in the gem against Gem::BUNDLED_GEMS::SINCE:

require status on Ruby 4.0
logger bundled since 4.0.0 — must be declared
date, timeout, forwardable, fileutils, etc, yaml still default gems, stay undeclared

Constraint

Declared without a version constraint, matching how ruby/syslog and ruby/rbs handled the same transition. The logger gem supports well below this gemspec's required_ruby_version = ">= 2.5", so no floor is needed and older rubies keep resolving the version they already had.

Note on CI

This is not the current red CI, which is Security/YAMLLoad under Cookstyle 9.0.0 — fixed separately in #134. This PR is branched off main, so it will show those same 4 pre-existing lint offenses until #134 lands.

It does, however, break any consumer bundling this gem on Ruby 4.0 — including inspec-core and kitchen-omnibus-chef, both of which depend on license-acceptance.

@tas50
tas50 requested review from a team as code owners August 28, 2026 06:04
lib/license_acceptance/config.rb requires "logger" and Config#initialize calls
::Logger.new(IO::NULL) on the default path, so logger is a runtime dependency in
practice. It was never declared, which was harmless while logger was a default
gem.

Ruby 4.0 moved logger from a default gem to a bundled gem:

  Gem::BUNDLED_GEMS::SINCE["logger"]  => "4.0.0"
  Gem::Specification.find_all_by_name("logger").first.default_gem?  => false

Bundled gems ship with Ruby but are not on the load path of a bundle that does
not ask for them, so under Ruby 4.0 the gem fails to load at all:

  before  LoadError: cannot load such file -- logger
          0 examples, 0 failures, 1 error occurred outside of examples
  after   124 examples, 0 failures

Declared without a constraint, matching how ruby/syslog and ruby/rbs handled the
same transition. The logger gem supports well below the gemspec's
required_ruby_version of >= 2.5, so no floor is needed and older rubies keep
resolving the version they already had.

logger is the only require in lib that this affects. date, timeout, forwardable,
fileutils, etc and yaml are all still default gems on 4.0 and stay undeclared.

This is not the current CI failure, which is Security/YAMLLoad under Cookstyle
9.0.0 and is fixed separately. It does break any consumer bundling this gem on
Ruby 4.0, including inspec-core and kitchen-omnibus-chef.

Signed-off-by: Tim Smith <tsmith84@proton.me>
@tpowell-progress
tpowell-progress force-pushed the fix/declare-logger-dependency branch from 985b037 to 17be1fc Compare September 4, 2026 15:24
@tpowell-progress
tpowell-progress merged commit bf67a9f into chef:main Sep 4, 2026
58 checks passed
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 this pull request may close these issues.

2 participants