Skip to content

Comments

fix(windows): SessionStart hook fails with Git Bash paths#507

Open
shlokmestry wants to merge 1 commit intoobra:mainfrom
shlokmestry:fix/windows-sessionstart-hook-path
Open

fix(windows): SessionStart hook fails with Git Bash paths#507
shlokmestry wants to merge 1 commit intoobra:mainfrom
shlokmestry:fix/windows-sessionstart-hook-path

Conversation

@shlokmestry
Copy link

@shlokmestry shlokmestry commented Feb 19, 2026

Motivation and Context

On Windows, the SessionStart hook fails because ${CLAUDE_PLUGIN_ROOT} resolves to a Windows-style path (e.g. C:\Users\...), which Git Bash cannot execute directly as a script path.

This causes session-start.sh to fail on every Claude startup.

This change runs the hook through bash -lc and converts the plugin root to a Unix-style path using cygpath -u when available.

How Has This Been Tested?

  • Verified JSON structure is valid
  • Confirmed no behavior change on macOS
  • The cygpath conversion only executes when available (Windows Git Bash)
  • On systems without cygpath, behavior remains unchanged

Breaking Changes

None.

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change
  • Documentation update

Additional Context

This provides a minimal cross-platform fix without introducing OS-specific branching or additional wrapper scripts.

Fixes #504

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced Windows compatibility for session initialization to improve reliability across different operating systems. The session startup functionality now works properly on Windows while maintaining consistent behavior on macOS and Linux platforms. Improved path handling ensures proper execution in various system environments.

@coderabbitai
Copy link

coderabbitai bot commented Feb 19, 2026

📝 Walkthrough

Walkthrough

The SessionStart hook command in hooks.json was updated to use a Windows-compatible wrapper that converts CLAUDE_PLUGIN_ROOT via cygpath before executing the session-start.sh script, resolving Git Bash path resolution issues on Windows.

Changes

Cohort / File(s) Summary
SessionStart Hook Configuration
hooks/hooks.json
Updated SessionStart hook command from direct script path to a Windows-friendly wrapper that uses cygpath to convert CLAUDE_PLUGIN_ROOT and then executes the session-start.sh script, fixing path resolution failures in Git Bash on Windows.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 A Windows path that wouldn't play,
With cygpath magic, saves the day,
Git Bash now greets the session with cheer,
No more errors when Claude appears!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: fixing Windows compatibility for the SessionStart hook by resolving Git Bash path issues.
Linked Issues check ✅ Passed The PR implements the proposed fix from issue #504 by converting Windows-style paths to Git Bash-compatible format using cygpath, directly addressing the hook execution failure.
Out of Scope Changes check ✅ Passed The change is limited to the SessionStart hook command in hooks.json and is directly scoped to fix the Windows path issue described in issue #504.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
hooks/hooks.json (1)

9-9: Consider dropping the -l (login) flag from bash -lc

-l causes bash to source /etc/profile and ~/.bash_profile on every hook invocation. On macOS/Linux this is unnecessary overhead and can trigger side effects from user login scripts (conda/pyenv/nvm initialisers, cd calls, early exits, etc.). On Windows/Git Bash, cygpath lives in /usr/bin and is typically present in PATH even without a login shell, so -l likely isn't required there either.

If cygpath is consistently found without a login shell (as it is in standard Git Bash installations), change -lc to -c:

♻️ Proposed refactor
-            "command": "bash -lc 'ROOT=\"${CLAUDE_PLUGIN_ROOT}\"; if command -v cygpath >/dev/null 2>&1; then ROOT=\"$(cygpath -u \"$ROOT\")\"; fi; \"$ROOT/hooks/session-start.sh\"'",
+            "command": "bash -c 'ROOT=\"${CLAUDE_PLUGIN_ROOT}\"; if command -v cygpath >/dev/null 2>&1; then ROOT=\"$(cygpath -u \"$ROOT\")\"; fi; \"$ROOT/hooks/session-start.sh\"'",

If there is a confirmed reason that cygpath requires a login shell on the target Windows environment, add a comment in the PR description documenting that requirement.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@hooks/hooks.json` at line 9, The hook command currently invokes bash with the
login flag (`bash -lc '...') which forces sourcing of login profiles and can
cause side effects; update the "command" entry in hooks.json to use `bash -c`
instead of `bash -lc` so the hook runs a non-login shell (keep the existing
cygpath handling and $CLAUDE_PLUGIN_ROOT expansion and the call to
"hooks/session-start.sh"); if there's a confirmed environment-specific need for
a login shell (e.g., cygpath only available when sourcing profiles), add a brief
comment in the PR explaining that constraint instead of keeping `-l`.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@hooks/hooks.json`:
- Line 9: The hook command currently invokes bash with the login flag (`bash -lc
'...') which forces sourcing of login profiles and can cause side effects;
update the "command" entry in hooks.json to use `bash -c` instead of `bash -lc`
so the hook runs a non-login shell (keep the existing cygpath handling and
$CLAUDE_PLUGIN_ROOT expansion and the call to "hooks/session-start.sh"); if
there's a confirmed environment-specific need for a login shell (e.g., cygpath
only available when sourcing profiles), add a brief comment in the PR explaining
that constraint instead of keeping `-l`.

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.

SessionStart hook fails on Windows: session-start.sh not found

1 participant