fix: quote $CLAUDE_PROJECT_DIR in hook commands to handle paths with spaces (non-Windows) #83
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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_DIRwithout 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_DIRvariable 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.pyandcc_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.