Skip to content

Exclude the Windows gemspec from the chef git source - #56

Open
tas50 wants to merge 2 commits into
chef:mainfrom
tas50:fix/ci-windows-gemspec
Open

Exclude the Windows gemspec from the chef git source#56
tas50 wants to merge 2 commits into
chef:mainfrom
tas50:fix/ci-windows-gemspec

Conversation

@tas50

@tas50 tas50 commented Aug 22, 2026

Copy link
Copy Markdown

Problem

CI has been failing on every job (Ruby 3.1 through 3.4) since the last green scheduled run. Both rake unit and rake acceptance fail before running anything:

bundler: failed to load command: rake
Could not find chef-cli-6.1.34, win32-api-1.10.1 in locally installed gems (Bundler::GemNotFound)

Cause

chef's repo ships chef-universal-mingw-ucrt.gemspec next to chef.gemspec. It loads chef.gemspec, switches the platform, and adds the Windows only dependencies, but it keeps the gem name chef:

gemspec = Gem::Specification.load(File.expand_path("chef.gemspec", __dir__))
gemspec.platform = Gem::Platform.new(%w{universal mingw-ucrt})
gemspec.add_dependency "win32-api", "~> 1.10.0"
...
gemspec.add_dependency "chef-powershell", "~> 18.6.6"

Bundler loads every gemspec it finds in a git source (default glob {,*,*/*}.gemspec), so it picks up the mingw variant too. The resulting lockfile lists the Windows gems as dependencies of chef on every platform:

    chef (19.4.14)
      ...
      win32-api (~> 1.10.0)
      win32-certstore (~> 0.6.15)
      win32-eventlog (= 0.6.7)

Those gems cannot install on Linux or macOS, so the bundle is never fully installed and bundle exec fails. This is reproducible locally on a clean checkout, and it is why bundle install appears to succeed while bundle check still reports missing gems.

Nothing changed in this repo to trigger it, which is why it started failing on an unrelated push.

Fix

Restrict the git source glob so the mingw variant is skipped:

gem "chef", git: "https://github.com/chef/chef.git", glob: "{chef,chef-*/chef-*}.gemspec"

That still matches the gemspecs the resolution needs from the checkout:

chef.gemspec
chef-bin/chef-bin.gemspec
chef-config/chef-config.gemspec
chef-utils/chef-utils.gemspec

and leaves out chef-universal-mingw-ucrt.gemspec.

ohai is unaffected, its repo only has the one gemspec, so it is left alone.

Testing

Verified on a clean git archive checkout of main, running the same commands CI runs:

  • bundle install completes, and bundle check reports "The Gemfile's dependencies are satisfied"
  • No win32-* or chef-powershell entries remain in the resolved lockfile
  • bundle exec rake unit206 examples, 0 failures, exit 0
  • bundle exec rake acceptance — all example suites pass, exit 0

Without the change, the same checkout reproduces the CI failure exactly.

Also in this PR

Adds Ruby 4.0 to the CI matrix, so the suite is covered on 3.1 through 4.0. Verified locally on Ruby 4.0.6: rake unit and rake acceptance both exit 0.

CI has been failing on every job since the last green scheduled run, with:

  Could not find chef-cli-6.1.34, win32-api-1.10.1 in locally installed
  gems (Bundler::GemNotFound)

chef's repo ships chef-universal-mingw-ucrt.gemspec alongside
chef.gemspec. That file loads chef.gemspec, sets the platform to
universal-mingw-ucrt and adds the Windows only dependencies, but it keeps
the gem name "chef".

Bundler loads every gemspec it finds in a git source, so it picked up the
mingw variant as well and win32-api, chef-powershell and the other
win32-* gems ended up in the resolution on every platform. Those gems
cannot install on Linux or macOS, so the bundle was never fully
installed and bundle exec failed.

Restrict the git source to chef.gemspec and the chef-* subdirectory
gemspecs, which keeps chef-config, chef-utils and chef-bin resolving from
the git checkout while leaving the mingw variant out.

ohai is unaffected, its repo only has the one gemspec.

Signed-off-by: Tim Smith <tsmith84@proton.me>
Ruby 4.0 is released and chefspec supports it, so add it to the CI
matrix alongside 3.1 through 3.4.

Signed-off-by: Tim Smith <tsmith84@proton.me>
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.

1 participant