Skip to content

fix(mcp): expand ~ with os.UserHomeDir; run tests on Windows in CI - #209

Merged
JordanCoin merged 4 commits into
mainfrom
fix/139-windows-home
Oct 11, 2026
Merged

JordanCoin merged 4 commits into
mainfrom
fix/139-windows-home

Conversation

@JordanCoin

@JordanCoin JordanCoin commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Bug

mcp/main.go and mcp/topology.go expanded ~/ by joining os.Getenv("HOME"). On Windows HOME is normally unset, so ~/proj became proj and filepath.Abs resolved it against the server's cwd: a spurious "not accessible" error, or a confident analysis of the wrong project if a same-named directory sat next to the cwd.

The issue counted 9 sites; main today has 4 (validateProjectPath, handleListProjects, handleStatus, topologyProjectRoot). All four now route through one helper:

func expandHome(path string) (string, error)

based on os.UserHomeDir(), handling ~, ~/ and ~\, and returning an error that names the path when no home directory is known rather than guessing relative to cwd. handleListProjects had its own copy of the expansion before calling validateProjectPath; the copy is gone.

Tests

  • TestExpandHome (mcp/main_test.go): ~/x, ~\x, bare ~, untouched plain path, and the no-home case asserting an error that names the path.
  • setHome(t, dir) sets HOME and USERPROFILE together; the three existing tests that set only HOME switched to it. Those passed on Windows before by supplying the variable Windows would not have.

CI

The Test matrix gains one windows-latest job on Go 1.26 (the Build job already ran there, but no test ever did). ast-grep is installed there with pip, same as Linux. Unix-only tests already carry build tags or t.Skip; untouched.

go build ./... && go test ./... && gofmt -l . clean on macOS. The Windows run is this PR's own CI. Its first run showed 124 pre-existing failures, none touching this change; they are listed by cause in #214, and the Windows job is continue-on-error (informational) until that list is empty.

Fixes #139

🤖 Generated with Claude Code

https://claude.ai/code/session_01NRaBgKRAZMX9hjbkkefA7T

Four sites joined os.Getenv("HOME") to expand "~/". HOME is normally
unset on Windows, so "~/proj" became "proj" and filepath.Abs resolved it
against the server's cwd: either a spurious error or, worse, a confident
analysis of the wrong project. One helper, expandHome, now resolves "~",
"~/" and "~\" through os.UserHomeDir and returns an error naming the path
when no home directory is known.

Tests set HOME and USERPROFILE together (setHome) so they prove the same
behaviour on every OS; the old HOME-only tests passed on Windows by
supplying the variable Windows would not have. CI gains one Windows test
job (newest Go) so a whole platform is no longer asserted by a build.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NRaBgKRAZMX9hjbkkefA7T
Copilot AI balanced review requested due to automatic review settings October 11, 2026 19:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@JordanCoin
JordanCoin merged commit 5ea7b24 into main Oct 11, 2026
12 of 13 checks passed
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.

windows: '~' expansion uses os.Getenv("HOME") in 9 places, and CI never runs tests on Windows

2 participants