Skip to content

Add Ruby 4.0 support - #626

Closed
tas50 wants to merge 1 commit into
mizzy:masterfrom
tas50:ruby-4.0-support
Closed

Add Ruby 4.0 support#626
tas50 wants to merge 1 commit into
mizzy:masterfrom
tas50:ruby-4.0-support

Conversation

@tas50

@tas50 tas50 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Problem

require "serverspec" fails on Ruby 4.0:

LoadError: cannot load such file -- logger
    from lib/serverspec.rb:4:in '<top (required)>'

net-ssh (pulled in via specinfra) does require 'logger' on its first line but does not declare the dependency. That was fine while logger was a default gem — always on the load path. As of Ruby 3.5 / 4.0 it is a bundled gem, so Bundler no longer puts it on the load path unless something in the dependency graph asks for it.

This is the same class of fix specinfra already made for base64 during the Ruby 3.4 cycle.

Changes

  • Declare logger as a runtime dependency in the gemspec.
  • Add "4.0" to the CI matrix.

Compatibility with the existing matrix

The unconditional dependency resolves on every Ruby currently tested, because the oldest logger releases declare no Ruby floor at all:

Ruby resolves
2.2 logger 1.3.0 (required_ruby_version: >= 0)
2.3 logger 1.5.3
2.5 – 4.0 logger 1.7.0

So the Ruby 2.2 floor is unaffected.

Verification

Full suite on Ruby 4.0.6:

650 examples, 0 failures

Before this change the same suite reported 6 errors occurred outside of examples, all cannot load such file -- logger.

net-ssh, pulled in via specinfra, requires "logger" at load time. As of
Ruby 3.5 / 4.0 "logger" is a bundled gem rather than a default gem, so it
is no longer on the load path inside a bundle unless it is declared. Without
it, `require "serverspec"` fails on Ruby 4.0 with:

    LoadError: cannot load such file -- logger

Declare logger as a runtime dependency and add Ruby 4.0 to the CI matrix.
The full suite (650 examples) passes on Ruby 4.0.6.

Signed-off-by: Tim Smith <tsmith84@proton.me>
@tas50
tas50 force-pushed the ruby-4.0-support branch from 47af679 to 9f0d98a Compare August 29, 2026 00:23
@mizzy

mizzy commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Thanks for tracking this down — the diagnosis is right, but the fix belongs in specinfra.

The require "logger" comes from specinfra/backend/ssh.rbnet/ssh.rb; serverspec's own lib never references logger. The base64 precedent you cite was mizzy/specinfra#755, against specinfra.gemspec. Declaring it here would also leave itamae (the other specinfra consumer) broken.

Note the CI matrix hunk can't be split out and merged on its own — ci (4.0) only passes here because the gemspec change pulls logger into the bundle. So this needs to land in specinfra first, then serverspec bumps its specinfra floor and adds 4.0 to the matrix.

One thing to watch in the specinfra PR: an unconditional logger dependency breaks Ruby 2.2 (ci (2.2) fails on this branch, master is green). logger 1.3.0 declares no required_ruby_version but uses &. internally, so it shadows the stdlib logger and dies with a SyntaxError. specinfra may just want to drop 2.2 — it's EOL since 2018 and ships in no currently-supported distro — but that's a call for that repo.

Closing here; would you be up for opening it against mizzy/specinfra?

@mizzy mizzy closed this Aug 30, 2026
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