Skip to content

Hook fails on first session in a project: shell redirect opens .remember/logs/hook-errors.log before script creates the dir #58

@pp-vkrasikov

Description

@pp-vkrasikov

Symptom

On the first session in any project (or after deleting .remember/), every hook fires this non-blocking failure:

PostToolUse:Read hook error
Failed with non-blocking status code: /bin/sh:
/path/to/project/.remember/logs/hook-errors.log: No such file or directory

Triggers for SessionStart and PostToolUse on every tool call. Subsequent sessions in the same project work fine — but only because the first session eventually creates .remember/logs/ (via scripts/log.sh:38) for a later call, not the one whose stderr is being redirected right now.

Root cause

hooks/hooks.json defines:

{
  "type": "command",
  "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/session-start-hook.sh\" 2>> \"${CLAUDE_PROJECT_DIR:-.}/.remember/logs/hook-errors.log\""
}

The shell opens the stderr file descriptor for hook-errors.log before the script body runs — so the mkdir -p inside scripts/log.sh:38 cannot help: the redirect is evaluated by the parent shell, and it fails when the directory doesn't exist yet.

Reproduce

rm -rf <project>/.remember/
# open a Claude Code session in <project>
# every hook reports: "No such file or directory"

Fix

Prepend mkdir -p to each command in hooks/hooks.json so the redirect target always exists. Idempotent and cheap:

{
  "type": "command",
  "command": "mkdir -p \"${CLAUDE_PROJECT_DIR:-.}/.remember/logs\" && bash \"${CLAUDE_PLUGIN_ROOT}/scripts/session-start-hook.sh\" 2>> \"${CLAUDE_PROJECT_DIR:-.}/.remember/logs/hook-errors.log\""
}

Same change for the PostToolUse entry.

Version

remember 0.5.0 (via claude-plugins-official marketplace cache)

Workaround for users

Until a release ships, manually mkdir -p <project>/.remember/logs before the first session, or patch the cached hooks.json locally (will be overwritten on plugin update).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions