fix(install): don't crash the PowerShell installer when $PROFILE is unset#2469
Open
abhay-codes07 wants to merge 1 commit into
Open
fix(install): don't crash the PowerShell installer when $PROFILE is unset#2469abhay-codes07 wants to merge 1 commit into
abhay-codes07 wants to merge 1 commit into
Conversation
…nset `Ensure-ProfileBlock` did `Split-Path -Parent $PROFILE` to locate the user's PowerShell profile. PowerShell leaves `$PROFILE` as an empty string when it cannot resolve the profile path for the current user (a fresh account with no Documents folder yet, a service or CI context, a redirected profile). Split-Path then throws "Cannot bind argument to parameter 'Path' because it is an empty string", and because the script runs under `$ErrorActionPreference = 'Stop'` that aborts the whole installer with a cryptic error at the very end, after the `headroom` wrapper and the persistent User PATH entry were already written. The user sees a non-zero exit and assumes the install failed. Skip the profile convenience block when `$PROFILE` is empty and log why. The PATH is already persisted for new sessions by the separate `Ensure-PathEntry` call, so the only thing skipped is auto-refreshing PATH inside the current profile, which does not exist in that environment anyway. This is exactly the path `test_powershell_native_installer_supports_persistent_docker_lifecycle` drives (it runs the installer under a temp HOME whose profile cannot be resolved); the test now passes instead of failing on the Split-Path error.
abhay-codes07
requested review from
DevanshiVyas and
JerrettDavis
as code owners
July 21, 2026 17:41
JerrettDavis
approved these changes
Jul 21, 2026
JerrettDavis
left a comment
Collaborator
There was a problem hiding this comment.
Approved. The guard is correctly placed before Split-Path, and the behavior is scoped to the missing-profile-path case while still preserving the persistent User PATH update for new sessions.
Local validation in an isolated PR worktree:
uv run --frozen --extra dev python -m pytest tests/test_install/test_native_installers.py::test_powershell_native_installer_supports_persistent_docker_lifecycle -q-> 1 passedgit diff --check upstream/main...HEAD-> clean
Contributor
PR governanceThis PR follows the template and is marked ready for human review. |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Description
The PowerShell installer (
scripts/install.ps1) crashes at the very end on any machine where PowerShell cannot resolve the current user's profile path.Ensure-ProfileBlocklocates the profile with:$PROFILEis an empty string when PowerShell cannot compute the profile path for the current user, which happens for a fresh account with no Documents folder yet, a service or CI context, or a redirected profile.Split-Path -Parent ''then throws:Because the script runs under
$ErrorActionPreference = 'Stop', that terminates the whole installer with a non-zero exit, even though it happens after theheadroomwrapper and the persistent User PATH entry were already written. The user sees a scary Split-Path error and assumes the install failed.Fix
Skip the profile convenience block when
$PROFILEis empty and log why.Ensure-PathEntryalready persists the User PATH for new sessions, so the only thing skipped is auto-refreshing PATH inside the current profile file, which does not exist in that environment anyway. Well-behaved environments with a real$PROFILEare unchanged.Type of Change
Changes Made
scripts/install.ps1: early-return fromEnsure-ProfileBlockwith an informational message when$PROFILEis null or empty, before theSplit-Pathcall.Testing
pytest)ruff check .)mypy headroom)Test Output
Real Behavior Proof
uv sync --extra proxy), pytest in the venv.install.ps1under a tempUSERPROFILEwith no Documents folder (the same setup the installer test uses). Confirmed$PROFILEresolves to an empty string in that context and thatSplit-Path -Parent $PROFILEthrows there, then re-ran the installer test with the fix.Split-Path : Cannot bind argument to parameter 'Path' because it is an empty stringand exit code 1 (and the test failed); after the fix the installer completes, writes the wrapper and PATH entry, logs that it skipped the profile update, and the test passes. Ran against the actual script.Review Readiness
Checklist