Skip to content

fix(glean-core): resolve HOME via os.homedir() so session-start works on Windows#30

Open
almacd35712 wants to merge 1 commit into
gleanwork:mainfrom
almacd35712:fix/windows-home-path-in-session-start
Open

fix(glean-core): resolve HOME via os.homedir() so session-start works on Windows#30
almacd35712 wants to merge 1 commit into
gleanwork:mainfrom
almacd35712:fix/windows-home-path-in-session-start

Conversation

@almacd35712
Copy link
Copy Markdown

Summary

The glean-core SessionStart hook prints "Glean is installed but no MCP server is configured" on every session under Windows + Git Bash, even when a Glean MCP server is in fact configured and connected.

Root cause: plugins/glean-core/scripts/session-start.sh runs

node -e "const c=require('$HOME/.claude.json'); ..."

Under Git Bash on Windows, $HOME expands to a Unix-style path like /c/Users/foo. Node on Windows cannot resolve that path with require(), so the snippet throws MODULE_NOT_FOUND, exits 1, and the hook falls through to emitting the session-unconfigured.txt template.

This PR resolves the home directory inside Node via os.homedir(), which returns a platform-correct absolute path on every OS. Behavior on macOS/Linux is unchanged.

Reproduction

On Windows + Git Bash with glean_default configured in ~/.claude.json:

$ claude mcp list
glean_default: https://<tenant>-be.glean.com/mcp/default (HTTP) - ✓ Connected

$ bash -c 'node -e "const c=require('"'"'$HOME/.claude.json'"'"'); ..."'
Error: Cannot find module '/c/Users/foo/.claude.json'

After the fix:

$ bash plugins/glean-core/scripts/session-start.sh ; echo "exit=$?"
exit=0

(silent, as expected when configured).

Test plan

  • On Windows + Git Bash, with a Glean server configured in ~/.claude.json, the script exits 0 silently.
  • On Windows + Git Bash, with no Glean server configured, the unconfigured template still fires.
  • Verify on macOS / Linux that the os.homedir() form behaves identically to the prior $HOME form (no behavior change expected).

The session-start hook used $HOME inside a node -e snippet to require
~/.claude.json. On Windows under Git Bash, $HOME expands to a Unix-style
path (e.g. /c/Users/foo) which Node on Windows cannot require(), so the
check throws, exits 1, and the 'Glean is installed but no MCP server is
configured' message fires on every session — even when a Glean server is
in fact configured.

Resolve the home directory inside Node via os.homedir() instead, which
returns a platform-correct path everywhere.
@almacd35712 almacd35712 requested a review from a team as a code owner April 25, 2026 20:33
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