Skip to content

fix: CHEF-33393 - Fall back to PowerShell syntax for arch detection in WinRM sessions#832

Merged
Nik08 merged 1 commit into
mainfrom
CHEF-33393-in-spec-package-resource-fails-in-kitchen-verify-on-windows
Jun 11, 2026
Merged

fix: CHEF-33393 - Fall back to PowerShell syntax for arch detection in WinRM sessions#832
Nik08 merged 1 commit into
mainfrom
CHEF-33393-in-spec-package-resource-fails-in-kitchen-verify-on-windows

Conversation

@Nik08

@Nik08 Nik08 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Description

On Windows Server 2025, wmic has been deprecated and removed. When train falls back to read_cmd_os for architecture detection, it runs echo %PROCESSOR_ARCHITECTURE% which is CMD batch syntax. However, WinRM sessions in Test Kitchen default to PowerShell, where %VAR% expansion is not supported — the literal string %PROCESSOR_ARCHITECTURE% is returned instead.

This left os.arch as nil/unknown, which caused the InSpec package resource to skip WOW6432Node registry paths, making 32-bit packages (e.g. .NET Framework SDK, VC++ x86 redistributables) appear as "not installed" during kitchen verify.

Fix: In read_cmd_os, detect when the CMD command returns the unexpanded literal and fall back to the PowerShell-native $env:PROCESSOR_ARCHITECTURE.

Related Issue

CHEF-33393 — InSpec Package Resource Fails in Kitchen Verify on Windows

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New content (non-breaking change)
  • Breaking change (a content change which would break existing functionality or processes)

Checklist:

  • I have read the CONTRIBUTING document.

…n PowerShell WinRM sessions

When wmic is unavailable (e.g., Windows Server 2025 where wmic is deprecated),
read_cmd_os falls back to 'echo %PROCESSOR_ARCHITECTURE%'. In PowerShell-based
WinRM sessions (the default for Test Kitchen), CMD-style variable expansion is
not supported and the literal string '%PROCESSOR_ARCHITECTURE%' is returned.

This fix detects the unexpanded literal and falls back to the PowerShell-native
syntax '$env:PROCESSOR_ARCHITECTURE', ensuring os.arch is correctly set to
'x86_64' in PowerShell WinRM sessions on Windows 2025.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Nik08 <[email protected]>
@Nik08 Nik08 requested a review from a team as a code owner June 5, 2026 12:01
@Nik08 Nik08 merged commit 259f9fa into main Jun 11, 2026
62 of 63 checks passed
Nik08 added a commit to chef/chef-web-docs that referenced this pull request Jun 12, 2026
Fixed Windows architecture detection over WinRM when os.arch was missing or unknown. Adds robust fallback detection in Train and InSpec. ([#7935](inspec/inspec#7935), train [#832](inspec/train#832))

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Nik08 <[email protected]>
Nik08 added a commit to chef/chef-web-docs that referenced this pull request Jun 12, 2026
Fixed Windows architecture detection over WinRM when os.arch was missing or unknown. Adds robust fallback detection in Train and InSpec. ([#7935](inspec/inspec#7935), train [#832](inspec/train#832))

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Nik08 <[email protected]>
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