Skip to content

Bug: SessionHarvester fails silently on Linux — hardcoded macOS project directory path #680

@zulrang

Description

@zulrang

SessionHarvester.ts hardcodes a macOS-style project directory slug on line 30:

const PROJECTS_DIR = path.join(CLAUDE_DIR, "projects", `-Users-${USERNAME}--claude`);

Claude Code stores session transcripts under ~/.claude/projects/{cwd-slug}/, where the slug is derived
from the current working directory by replacing / and . with -. On macOS this produces
-Users-username--claude, but on Linux the home directory is /home/username, producing
-home-username--claude. The hardcoded macOS path causes the script to silently find no sessions and exit
with "No sessions found to harvest" on any non-macOS system.

Steps to Reproduce

  1. Run on a Linux system where $HOME is /home/
  2. Execute bun run SessionHarvester.ts --recent 10
  3. Output: No sessions found to harvest

Expected Behavior

SessionHarvester should detect the correct projects directory regardless of OS.

Fix

Replace the hardcoded slug with dynamic derivation from CLAUDE_DIR:

const CWD_SLUG = CLAUDE_DIR.replace(/[\/\.]/g, "-");
const PROJECTS_DIR = path.join(CLAUDE_DIR, "projects", CWD_SLUG);

This produces the correct slug on both macOS (-Users-username--claude) and Linux
(-home-username--claude).

Impact

  • Severity: High — the tool is completely non-functional on Linux
  • Scope: All Linux and WSL users
  • Failure mode: Silent — no error message, just "No sessions found"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions