Skip to content

save-session.sh: path resolution broken in plugin-mode installs #8

Closed

Description

@ryan6416

Bug

save-session.sh computes PROJECT_DIR and PIPELINE_DIR by navigating 3 directories up from $0:

PROJECT_DIR="$(cd "$(dirname "$0")/../../.." && pwd)"
PIPELINE_DIR="${PROJECT_DIR}/.claude/remember"

This works for manual installs (where the script lives at <project>/.claude/remember/scripts/save-session.sh), but breaks for plugin-mode installs where the script lives at:

~/.claude/plugins/cache/claude-plugins-official/remember/0.1.0/scripts/save-session.sh

Going 3 levels up from scripts/ lands at the plugin cache root (~/.claude/plugins/cache/claude-plugins-official/), not the project directory. This causes:

cd: /Users/.../.claude/plugins/cache/claude-plugins-official/.claude/remember: No such file or directory

Every auto-save silently fails.

Root cause

The other 3 hook scripts (session-start-hook.sh, post-tool-hook.sh, user-prompt-hook.sh) correctly use CLAUDE_PROJECT_DIR:

PROJECT="${CLAUDE_PROJECT_DIR:-.}"
PROJECT_DIR="$PROJECT"

save-session.sh does not — it computes from $0 instead.

Fix

# Line 57-58, change:
PROJECT_DIR="$(cd "$(dirname "$0")/../../.." && pwd)"
PIPELINE_DIR="${PROJECT_DIR}/.claude/remember"

# To:
PROJECT_DIR="${CLAUDE_PROJECT_DIR:-$(cd "$(dirname "$0")/../../.." && pwd)}"
PIPELINE_DIR="$(cd "$(dirname "$0")/.." && pwd)"
  • PROJECT_DIR uses CLAUDE_PROJECT_DIR (set by Claude Code for all hooks) with the old computation as fallback for manual installs.
  • PIPELINE_DIR resolves to one level up from scripts/ (the plugin root containing pipeline/), which works in both install modes.

Environment

  • Claude Code CLI
  • Plugin installed via /plugin marketplace (local scope)
  • macOS, Bash 5.x

Activity

  1. fdaviddpt commented on Apr 2, 2026

    @fdaviddpt
    Contributor

    This was already fixed in a prior update — save-session.sh line 57-58 now uses CLAUDE_PROJECT_DIR and CLAUDE_PLUGIN_ROOT with fallbacks, exactly as you suggested:

    PROJECT_DIR="${CLAUDE_PROJECT_DIR:-$(cd "$(dirname "$0")/../../.." && pwd)}"
    PIPELINE_DIR="${CLAUDE_PLUGIN_ROOT:-${PROJECT_DIR}/.claude/remember}"

    Duplicate of #7 (which covered the remaining unquoted path in hooks.json — now also fixed in 4d50166).

    Thanks for the detailed analysis, Ryan! The root cause description was spot-on. Appreciate you filing it.

    — Max

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