fix(ps1): replace null-conditional operator for PowerShell 5.1 compatibility#1975
Merged
mnriem merged 1 commit intogithub:mainfrom Mar 25, 2026
Merged
Conversation
…ibility The `?.` (null-conditional member access) operator requires PowerShell 7.1+, but Windows ships with PowerShell 5.1 by default. When AI agents invoke .ps1 scripts on Windows, they typically use the system-associated handler (5.1), causing a ParseException: Unexpected token '?.Path'. Replace the single `?.` usage with a 5.1-compatible two-step pattern that preserves the same null-safety behavior. Fixes github#1972
Contributor
There was a problem hiding this comment.
Pull request overview
This PR restores Windows PowerShell 5.1 compatibility for spec-kit’s shared PowerShell helpers by removing the PowerShell 7+ null-conditional member access operator from common.ps1, fixing script execution failures reported in #1972.
Changes:
- Replaced
?.Pathusage with a PowerShell 5.1-compatible null-safe pattern when resolving$StartDir. - Preserved the prior behavior where an unresolved path yields
$null.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
RbBtSn0w
pushed a commit
to RbBtSn0w/spec-kit
that referenced
this pull request
Mar 26, 2026
…ibility (github#1975) The `?.` (null-conditional member access) operator requires PowerShell 7.1+, but Windows ships with PowerShell 5.1 by default. When AI agents invoke .ps1 scripts on Windows, they typically use the system-associated handler (5.1), causing a ParseException: Unexpected token '?.Path'. Replace the single `?.` usage with a 5.1-compatible two-step pattern that preserves the same null-safety behavior. Fixes github#1972
jonasbokim
added a commit
to Jonas-Construction-Software/jonas-spec-kit-dev
that referenced
this pull request
Mar 26, 2026
…nc-main-2026-03-25 * upstream/main: (90 commits) fix(ps1): replace null-conditional operator for PowerShell 5.1 compatibility (github#1975) chore: bump version to 0.4.2 (github#1973) feat: Auto-register ai-skills for extensions whenever applicable (github#1840) docs: add manual testing guide for slash command validation (github#1955) Add AIDE, Extensify, and Presetify to community extensions (github#1961) docs: add community presets section to main README (github#1960) docs: move community extensions table to main README for discoverability (github#1959) docs(readme): consolidate Community Friends sections and fix ToC anchors (github#1958) fix(commands): rename NFR references to success criteria in analyze and clarify (github#1935) Add Community Friends section to README (github#1956) docs: add Community Friends section with Spec Kit Assistant VS Code extension (github#1944) chore: bump version to 0.4.1 (github#1953) Add checkpoint extension (github#1947) fix(scripts): prioritize .specify over git for repo root detection (github#1933) docs: add AIDE extension demo to community projects (github#1943) fix(templates): add missing Assumptions section to spec template (github#1939) chore: bump version to 0.4.0 (github#1937) fix(cli): add allow_unicode=True and encoding="utf-8" to YAML I/O (github#1936) fix(codex): native skills fallback refresh + legacy prompt suppression (github#1930) feat(cli): embed core pack in wheel for offline/air-gapped deployment (github#1803) ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the
?.(null-conditional member access) operator inscripts/powershell/common.ps1with a PowerShell 5.1-compatible pattern.Problem
The
?.operator requires PowerShell 7.1+, but Windows ships with PowerShell 5.1 by default. When AI agents (e.g., Cursor) invoke.ps1scripts on Windows, they typically use the system-associated handler (Windows PowerShell 5.1), causing:This breaks all spec-kit script execution on Windows for users without PowerShell 7+ installed, since
common.ps1is sourced by every other script.Fix
Single-line change in
scripts/powershell/common.ps1line 11:The replacement preserves identical null-safety behavior.
Audit
Performed a comprehensive scan of all 6
.ps1files for PowerShell 7+ syntax features (?.,??,??=,&&/||pipeline chains, ternary operators,-Parallel, 7.0+ cmdlets). This was the only instance. The CI script (create-release-packages.ps1) intentionally requires 7.0 via#requiresbut only runs in GitHub Actions.Fixes #1972