Skip to content

Conversation

@ck37
Copy link

@ck37 ck37 commented Nov 1, 2025

fix: resolve hook execution failures in paths with spaces (#82)

When cc-sessions is installed in directory paths containing spaces, all hooks fail to execute. This affects users on MacOS with installations in common locations like "Dropbox (Personal)", "Google Drive", or "My Documents". Windows paths already quoted the path correctly - potentially because this package has been tested more on windows.

Problem

The installers generate hook commands that reference $CLAUDE_PROJECT_DIR without proper shell quoting on Unix systems. When Claude Code expands this variable and the path contains spaces, the shell performs word-splitting and passes the path as multiple arguments to the Python or Node.js interpreter instead of a single path argument. This causes immediate "No such file or directory" errors and complete hook system failure.

While this is partially an upstream Claude Code bug (see their issues #5648, #1726, #5697, #397, #6023), we can implement defensive quoting to work around it.

Solution

All hook commands generated by both installers now properly quote the $CLAUDE_PROJECT_DIR variable expansion on Unix systems. Windows commands already used double quotes and were unaffected.

Changed from:

'python $CLAUDE_PROJECT_DIR/sessions/hooks/user_messages.py'

Changed to:

'python "$CLAUDE_PROJECT_DIR/sessions/hooks/user_messages.py"'

The fix modifies command generation in cc_sessions/install.py and cc_sessions/install.js, affecting seven hook commands and two statusline commands in each installer variant.

Testing

Validated proper quoting with test scripts (not committed) that verify all Unix and Windows command patterns using regex validation against the installer source code. All hook and statusline commands pass in both Python and JavaScript implementations. Also installed manually using python and javascript installers and confirmed that the issue is resolved.

Impact

Users with existing installations in space-free paths are unaffected. Users with installations in paths containing spaces will need to reinstall for the fix to take effect.

…spaces

Adds double quotes around $CLAUDE_PROJECT_DIR variable expansions in both
Python and JavaScript installers. Fixes hook execution failures when
cc-sessions is installed in directory paths containing spaces.

Fixes GWUDCAP#82
@ck37 ck37 mentioned this pull request Nov 4, 2025
@satoastshi satoastshi self-assigned this Dec 1, 2025
@satoastshi satoastshi added the pyoing this issue was v gud made me pyoing label Dec 1, 2025
@satoastshi
Copy link
Contributor

Will inline into next release - great PR. Thank you very much - will credit you on release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pyoing this issue was v gud made me pyoing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants