Skip to content

feat(adopt): make the diagnostics work on Windows - #138

Merged
fylorn merged 4 commits into
mainfrom
feat/windows-adopt-env
Sep 23, 2026
Merged

fylorn merged 4 commits into
mainfrom
feat/windows-adopt-env

Conversation

@fylorn

@fylorn fylorn commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Two adoption diagnostics only knew how to look at a Unix machine.

Same-name environment variables. Windows has no shell rc files; the variable lives in the registry. Both HKCU\Environment and HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment are checked, since a machine-level value overrides the client config just the same. Only names are reported, never values.

Each conflict now carries its own fix instead of the shared finding building a sed command:

  • Unix: sed -i '' '{line}d' {path} (unchanged)
  • Windows: reg delete "HKCU\Environment" /v NAME /f, and for the machine key a note that it needs an administrator terminal. It deletes rather than blanks the value, because an empty variable still counts as set.

The location ({path} in "{name} is already set in {path}") is back to plain English: a file path on Unix, a registry key on Windows.

New message codes for lite to translate: adopt.diag.unset_env, adopt.diag.unset_env_machine.

Process start times. ps does not exist on Windows. Processes are enumerated with CreateToolhelp32Snapshot and their creation time read with GetProcessTimes; processes this user cannot open are skipped.

Tests that write a .zshrc or parse ps output are gated to non-Windows.

Verification

  • macOS: cargo fmt, cargo clippy --all-targets -D warnings, cargo test --workspace all pass.
  • The two Windows functions were extracted into a scratch crate and passed cargo clippy --target x86_64-pc-windows-msvc --all-targets -D warnings (a planted type error was caught, so the check is real). The Windows CI job here is the full check.

🤖 Generated with Claude Code

fylorn and others added 4 commits September 23, 2026 20:12
Two of the adoption diagnostics only knew how to look at a Unix machine.

Same-name variables. On Windows nothing is exported from a shell file;
the variable lives in the registry, either per user (HKCU\Environment)
or for the whole machine (HKLM\...\Session Manager\Environment). Both
are read, because a machine-level value overrides our config just as
well and the report would otherwise say "nothing else sets it". Only
the name is reported, never the value.

Each conflict now carries its own fix, because the two platforms fix it
differently: a `sed` line delete on Unix, `reg delete` on Windows (with
a note that the machine key needs an administrator terminal). Deleting,
not blanking: an empty variable still counts as set.

The location went into an English sentence, so it is English again:
a path on Unix, a registry key on Windows. The line number stays in
the sed command where it is actually used.

Process start times. `ps` does not exist on Windows; processes are
enumerated with a ToolHelp snapshot and their creation time read with
GetProcessTimes, skipping the ones this user cannot open.

The tests that write a .zshrc or parse `ps` output are Unix-only now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
resolve() is the same code on both platforms, so the tests that cover
it should be as well. A machine that cannot create symlinks (Windows
without admin or developer mode) skips them; CI runs as admin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn
fylorn merged commit e91f4af into main Sep 23, 2026
2 checks passed
@fylorn
fylorn deleted the feat/windows-adopt-env branch September 23, 2026 12:30
fylorn added a commit that referenced this pull request Sep 23, 2026
#138 folded the Unix and Windows findings about same-name variables into
one message: `adopt.diag.shell_export` lost its `line` argument and got a
new English sentence, and `no_exports.detail` gained a `looked`
argument. lite translates by code with the arguments of the released
version, so its Chinese would have read "line undefined" and claimed
.zshrc was checked on Windows.

The Unix messages are back exactly as in v0.30.0. Windows says different
sentences, so it gets its own codes instead of sharing one:
adopt.diag.registry_env, adopt.diag.registry_env.overrides,
adopt.diag.no_registry_env and adopt.diag.no_registry_env.detail. Each
platform branch now builds its whole sentences; the shared finding code
only assembles them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fylorn added a commit that referenced this pull request Sep 23, 2026
#138 folded the Unix and Windows findings about same-name variables into
one message: `adopt.diag.shell_export` lost its `line` argument and got a
new English sentence, and `no_exports.detail` gained a `looked`
argument. lite translates by code with the arguments of the released
version, so its Chinese would have read "line undefined" and claimed
.zshrc was checked on Windows.

The Unix messages are back exactly as in v0.30.0. Windows says different
sentences, so it gets its own codes instead of sharing one:
adopt.diag.registry_env, adopt.diag.registry_env.overrides,
adopt.diag.no_registry_env and adopt.diag.no_registry_env.detail. Each
platform branch now builds its whole sentences; the shared finding code
only assembles them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fylorn added a commit that referenced this pull request Sep 23, 2026
#138 folded the Unix and Windows findings about same-name variables into
one message: `adopt.diag.shell_export` lost its `line` argument and got a
new English sentence, and `no_exports.detail` gained a `looked`
argument. lite translates by code with the arguments of the released
version, so its Chinese would have read "line undefined" and claimed
.zshrc was checked on Windows.

The Unix messages are back exactly as in v0.30.0. Windows says different
sentences, so it gets its own codes instead of sharing one:
adopt.diag.registry_env, adopt.diag.registry_env.overrides,
adopt.diag.no_registry_env and adopt.diag.no_registry_env.detail. Each
platform branch now builds its whole sentences; the shared finding code
only assembles them.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn fylorn mentioned this pull request Sep 23, 2026
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