Skip to content

Hook commands fail in git worktrees: .remember/logs/ not created before stderr redirect #31

Closed

Description

@PatrickHeneise

Problem

Both hook commands in hooks/hooks.json redirect stderr to a log file inside .remember/logs/ that may not exist yet:

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

The 2>> redirect opens the file before the script runs. If .remember/logs/ doesn't exist, the shell fails with:

/bin/sh: <path>/.remember/logs/hook-errors.log: No such file or directory

This happens on every SessionStart and PostToolUse event, surfacing in Claude Code as non-blocking hook errors. The scripts themselves do mkdir -p internally, but they never run because the redirect fails first.

When it reproduces

Reliably in git worktrees created by Claude Code's isolation: "worktree" agent option — CLAUDE_PROJECT_DIR is set to the worktree root, which has no .remember/ directory. Also reproduces on the first session in any fresh project checkout.

Suggested fix

Prepend mkdir -p to both hook commands so the directory exists before the redirect:

"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\""

Applied locally as a workaround and it silences the errors without affecting functionality.

Version

[email protected] (claude-plugins-official marketplace)

Activity

  1. fdaviddpt commented on Apr 25, 2026

    @fdaviddpt
    Contributor

    Fixed in #33 — bootstrap-dirs.sh now creates the .remember/logs/ directory before any stderr redirect. hooks.json no longer contains inline 2>> redirects.

    Thank you @PatrickHeneise for reporting this! With 20k installs, every fresh-project bug report helps us catch what our own testing missed. The fix includes 17 tests covering fresh projects, partial state, git worktrees, read-only filesystems, and more — so this class of bug shouldn't come back.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions