Skip to content

fix(install): install.ps1 knows whether a new terminal would run what it installed, and says only what is so - #1108

Merged
David-Noble-at-work merged 5 commits into
developfrom
fix/1050-install-ps1-says-to-run-as
Oct 21, 2026
Merged

David-Noble-at-work merged 5 commits into
developfrom
fix/1050-install-ps1-says-to-run-as

Conversation

@David-Noble-at-work

@David-Noble-at-work David-Noble-at-work commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Lane 34 of #949.

  • Whether a new terminal would run what was installed (install.ps1 says to run as Administrator for a per-user PATH change, and prints an empty Next steps heading #1050).
    • The check compared the install directory's name, as a string, with this session's PATH. A session opened before the PATH changed is stale, a folder can be named many ways, and another copy of the program can come first.
    • Get-CommandOnPersistentPath gets a program as Get-Command does, from the PATH a new terminal searches: the machine PATH then the user PATH, as the registry stores them, each entry as written, empty entries skipped. Names without an extension take PATHEXT's extensions, through a case-insensitive map. It returns Get-Command's ApplicationInfo, takes -All, and splits into begin and process.
    • The installer asks it with -All and compares each copy with the installed file by Get-FileIdentity: the volume serial number and 128-bit file ID from GetFileInformationByHandleEx. A hard link, a symbolic link or a junction to the installed file counts as the installed file; a copy does not.
    • Rulings, 2026-10-20: "we aren't doing a string compare"; the function's name, shape and map; "Use -all and a robust technique for determining whether they're exactly the same node in the file system".
  • The advice follows the answer.
    • On the PATH: "Verify installation:", as before.
    • Not on the PATH, or another copy first: "Add it to your PATH:" with no "(run as Administrator)", since the User scope needs none, and "then open a new terminal".
    • Another copy in a machine PATH folder: no user PATH change can come before it, so the advice says to remove it, or put the directory first in the machine PATH, as an administrator (ruled "A").
  • "Next steps:" only with a step. As install.sh does: only when a layer was registered or skipped. A run that changed no layer ends with the documentation line.
  • The suites. Both now run a case with every layer registered, base being a working tree made with git init. The install.ps1 suite also checks the PATH advice. Against 844a947f's install.ps1, the four new checks of the summary fail.
  • Both PowerShell files follow the style guide. Each function has a Go-style header (the guide's section 10, noblefactor-ops#325). The files are also laid out as sections 4 and 9 say:
    • a blank line around each control structure;
    • catch, finally and else on their own lines;
    • no one-line if expressions;
    • -ErrorAction Ignore rather than SilentlyContinue;
    • no line over 120 columns except the help's two examples.
  • Plan: docs/plans/fix/1050-install-ps1-says-to-run-as.md.

Resolves #1050

Test plan

  • By hand on danoble-wd11-3 under Windows PowerShell 5.1 and PowerShell 7, the installer's own PATH block against the real PATH:
    • installed where the PATH finds it, and a hard link to that copy: verify;
    • a copy off the PATH behind writ on the user PATH: the user advice;
    • a cmd copy behind System32's, and klist in System32 behind the Zulu JDK's: the machine advice.
  • Get-FileIdentity on danoble-wd11-3, both editions: the path in upper case, a hard link, a junction and a symbolic link match; a copy and an unrelated file do not.
  • The install.ps1 suite on danoble-wd11-3: 92 passed under 5.1 and 92 under 7; against 844a947f's install.ps1, its four new checks fail.
  • The install.sh suite: every check passed.
  • This script's pre-flight: CI's whole quality gate, both suites here, make test-race and make test-scenario
  • CI on this pull request, every leg

Written with AI assistance.

Signed-off-by: David Noble [email protected]
Assisted-by: Claude Code

Time

Marker UTC Elapsed
opened (first commit) 2026-10-20T22:59:55Z —
submitted (PR opened) 2026-10-20T23:55:28Z 0.9 h after opened
merged 2026-10-21T00:55:25Z 1 h after submitted; 1.9 h in all

Computed by the algorithm of noblefactor-ops#188 at merge.

@David-Noble-at-work
David-Noble-at-work merged commit 66669b9 into develop Oct 21, 2026
32 of 33 checks passed
@David-Noble-at-work
David-Noble-at-work deleted the fix/1050-install-ps1-says-to-run-as branch October 21, 2026 00:55
David-Noble-at-work added a commit that referenced this pull request Oct 21, 2026
…directory, and one list of checks serves CI and the local gate (#1111)

## Summary

Lane 35 of #949, with #670 and #1110 (ruled 2026-10-21: "We will do that change in the same PR as lane 35").

- **Every installer run removes its download directory (#1051).** #958 fixed `install.sh` leaving its download directory in `TMPDIR`, proved by hand; nothing tested it.
  - The `install.sh` suite checks after every run that the account's `TMPDIR` is empty; the `install.ps1` suite, that its temporary directory holds no `devlore-install-*`.
  - Each check names its run. Against installers patched to keep their directory, 55 of the `install.sh` suite's 66 checks fail and 36 of the `install.ps1` suite's 39; the others are runs refused before the directory is made.
  - Found doing it: under Windows PowerShell 5.1, `Add-Type`, which `install.ps1`'s file-identity check uses since #1108, leaves one empty, randomly named directory in `TEMP` a session. It is the .NET Framework compiler's, PowerShell 7 leaves none, and nothing records whose it is. Not cleaned up; ruled: "it sounds like powershell is unhygenic, not a litterbug." The design document's § 2 says so.
- **One list of checks (#670).** CI's quality gate, `make check` and every PR script's pre-flight were three lists that drifted.
  - `make quality-gate` runs every check CI's quality-gate job ran, in its order, plus `complexity` and `verify-ldflags`, which `make check` ran and no workflow did. Both pass on develop.
  - CI's quality-gate job installs its tools and runs `make quality-gate`; each check's reason, written in the workflow until now, moves beside it in the Makefile.
  - `make check` is `quality-gate` and `test`; `make shell-lint` is `star lint shell`, as CI's is.
  - `make check-all` runs the quality gate, the race tests, the scenarios and both installer suites, then names what CI alone runs: other platforms' legs and the Installers workflow's Windows and macOS legs. This script's pre-flight is `make check-all`.
- **The PowerShell analyzer, pinned once (#1110).** The Makefile pins PSScriptAnalyzer 1.25.0 beside golangci-lint. CI installs it with `Install-PSResource` at that version; #1108's `Install-Module` step found no PSGallery. The lint imports the pinned version and refuses when it is not installed, so a profile's unpinned install cannot drift from CI's.
- **Plan:** `docs/plans/chore/1051-installer-suites-never-check.md`.

Resolves #1051
Resolves #670
Resolves #1110

## Test plan

- [x] The `install.ps1` suite on danoble-wd11-3: 131 passed under Windows PowerShell 5.1 and 131 under PowerShell 7; against an installer that keeps its directory, the 36 leftover checks fail
- [x] The `install.sh` suite here: every check passed; against one that keeps its directory, 55 fail
- [x] CI's analyzer install, `Install-PSResource` at the pinned version, from a clean home; the pin check accepting 1.25.0 and refusing 1.24.0
- [x] This script's pre-flight: `make check-all`
- [ ] CI on this pull request, every leg; `quality-gate` running `make quality-gate`

Written with AI assistance.

Signed-off-by: David Noble <[email protected]>
Assisted-by: Claude Code
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.

install.ps1 says to run as Administrator for a per-user PATH change, and prints an empty Next steps heading

1 participant