Skip to content

fix(#287): Windows PowerShell 5.1 の module path を復元する - #290

Draft
rebuildup wants to merge 1 commit into
release-0-10-0from
287
Draft

rebuildup wants to merge 1 commit into
release-0-10-0from
287

Conversation

@rebuildup

Copy link
Copy Markdown
Owner

Refs #287

問題

PowerShell 7 (MSIX) のプロセスから powershell.exe を起動すると、PowerShell 7 が設定した PSModulePath を継承する。5.1 はそこで PowerShell 7 版の module set を autoload し、5.1 側の cmdlet を失う。

  • Get-FileHash 不在 → platforms/windows-11/converge.ps1 の Get-LockHash が例外 → mise-apply step が error。
  • Import-PowerShellDataFile 不在 → platforms/windows-11/verify.ps1 が実行できない。

Scheduled Task からは再現しない (task の environment は system のまま) が、PowerShell 7 の terminal から手動実行すると必ず再現する。

変更

  • platforms/windows-11/ps-module-path.ps1: Reset-WindowsPowerShellModulePath を追加。5.1 のときだけ PSModulePath を machine の値に戻す (PowerShell 7 は自前の module path を使うため変更しない)。
  • platforms/windows-11/converge.ps1 / verify.ps1 は起動時にこの reset を適用。
  • scripts/test-ps-module-path.ps1: Utility module を空の module で shadow して失敗を再現し、reset 後に Get-FileHash / Import-PowerShellDataFile が解決することを確認する。CI (ci.sh / ci.yml) に追加。

検証

  • scripts/test-ps-module-path.ps1: 全項目 PASS。
  • 実機: PowerShell 7 由来の環境で 5.1 を起動し、reset 後に両 cmdlet が解決することを確認。

Co-Authored-By: Claude Code noreply@anthropic.com

PowerShell 7 (MSIX) のプロセスから `powershell.exe` を起動すると、PowerShell 7
が設定した PSModulePath を継承する。5.1 はそこで PowerShell 7 版の module set を
autoload し、5.1 側の cmdlet を失う。

- `Get-FileHash` が無い → `platforms/windows-11/converge.ps1` の `Get-LockHash`
  が例外になり `mise-apply` step が error になる。
- `Import-PowerShellDataFile` が無い → `platforms/windows-11/verify.ps1` が
  実行できない。

Scheduled Task からは再現しない (task の environment は system のまま) が、
ユーザーが PowerShell 7 の terminal から実行すると必ず再現する。

- `platforms/windows-11/ps-module-path.ps1` に共通処理を置く。
- `converge.ps1` と `verify.ps1` は起動時に module path を machine の値に戻す。
  PowerShell 7 は自前の module path を使うため変更しない。
- `scripts/test-ps-module-path.ps1` で、Utility module を空の module で
  shadow して失敗を再現し、reset 後に Get-FileHash /
  Import-PowerShellDataFile が解決することを検証する。CI に追加。

Co-Authored-By: Claude Code <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 30, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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