Skip to content

fix(init): fall back to Windows environment paths when home lookup fails - #4254

Open
ryanduguid wants to merge 1 commit into
rtk-ai:developfrom
ryanduguid:fix/windows-claude-home-fallback
Open

ryanduguid wants to merge 1 commit into
rtk-ai:developfrom
ryanduguid:fix/windows-claude-home-fallback

Conversation

@ryanduguid

@ryanduguid ryanduguid commented Sep 26, 2026 •

Copy link
Copy Markdown

Summary

When native Windows home-directory lookup fails, resolve the Claude hook directory from USERPROFILE, then HOME. Preserve CLAUDE_CONFIG_DIR and native-home precedence. The fallback uses RTK's isolated user_dirs accessors, and child test environments also clear inherited USERPROFILE.

Integrated upstream develop ff9bd8e to resolve the merge conflict. The failure message now names the supported Windows recovery variable.

Related to #4229.

Evidence

  • Before integration, this branch conflicted in src/hooks/init/mod.rs. The resolved patch preserves upstream environment isolation and passes git diff --check.
  • Rust 1.98.1: formatting, Clippy and the complete Windows suite pass after the final diagnostic update: 3,928 tests, eight ignored, across 29 suites. The integration before that message-only update also passed formatting, Clippy and all 4,090 Linux tests, with eight ignored, across 29 suites.
  • Tests cover override and native-home precedence, USERPROFILE before HOME, absent and empty values, no usable home and the error text. The existing child-isolation test covers the added variable. Hook integrity tests remain in the full suite.
  • The initial Windows run lacked the existing tests' echo/cat utilities. Adding Git's Unix utilities after native Windows tools on PATH cleared the full rerun.
  • GitHub reports the published branch as mergeable, and license/cla passes at a63d4ce. Upstream's check-target job is skipped; this does not verify its test matrix.

Merge danger

Door: two-way. Blast radius: Windows paths.

The fallback applies when native lookup fails; the global home resolver and legacy-hook integrity gate retain their existing behaviour.

Unverified

The native Windows API failure is injected at the resolver boundary; a live Codex sandbox reproduction remains unverified. Linux verification predates the final diagnostic-only edit because the sandbox became unreachable. Upstream test CI, macOS verification and ignored integration tests remain unverified. Aikido timed out connecting and supplies no scan result.

@CLAassistant

CLAassistant commented Sep 26, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Adds a Windows-specific fallback for resolving the Claude hook directory when the native home-directory lookup fails, checking USERPROFILE then HOME while preserving CLAUDE_CONFIG_DIR and native home precedence. Includes new unit tests for the fallback, precedence, and empty-value rejection cases, plus a README update documenting the behavior.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Analyzed automatically by wshm · This is an automated analysis, not a human review.

@ryanduguid
ryanduguid marked this pull request as ready for review September 26, 2026 03:14
@ryanduguid
ryanduguid force-pushed the fix/windows-claude-home-fallback branch from fcaaabd to ec09bfb Compare October 10, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants