-
Notifications
You must be signed in to change notification settings - Fork 69
Description
Bug
ccplugin fails silently or crashes on macOS when deriving the Milvus collection name from the project path. The derive-collection.sh script calls realpath -m, which is a GNU coreutils flag not available in the BSD realpath shipped with macOS.
Environment
- memsearch: current main (post-0.2.0 ccplugin)
- OS: macOS (any version — BSD userland)
- ccplugin: installed via
~/.claude/plugins/
Steps to Reproduce
- Install ccplugin on macOS (without
brew install coreutils) - Open any Claude Code session in a project directory
- The
SessionStarthook sourcescommon.sh→ callsderive-collection.sh
Error
realpath: illegal option -- m
usage: realpath [-q] [path ...]
The script exits non-zero due to set -euo pipefail, which causes the hook to fail. On some setups this surfaces as a silent empty collection name, breaking all subsequent memsearch calls.
Root Cause
derive-collection.sh line 16 checks only for the existence of realpath:
if command -v realpath &>/dev/null; then
PROJECT_DIR="$(realpath -m "$PROJECT_DIR")"macOS ships /bin/realpath (BSD), which exists but does not support the -m flag (--canonicalize-missing — resolve path without requiring it to exist). Only GNU realpath (Linux / brew install coreutils) supports -m.
The check passes on macOS → the next line crashes immediately.
Expected Behavior
The script should fall through to the existing elif [ -d "$PROJECT_DIR" ] fallback, which uses cd && pwd and works correctly on all platforms.
Fix
Replace the existence check with a functional test:
# before
if command -v realpath &>/dev/null; then
# after
if realpath -m "$PROJECT_DIR" &>/dev/null 2>&1; thenThis tests whether -m actually works rather than whether the binary exists. On macOS the test fails silently and the fallback takes over. On Linux with GNU realpath it succeeds as before.
Platform matrix after fix:
| Platform | Before | After |
|---|---|---|
| Linux (GNU realpath) | ✅ works | ✅ works |
| macOS (BSD realpath) | ❌ crashes | ✅ falls through to cd fallback |
| Windows (WSL / Git Bash) | ✅ no realpath, skips | ✅ unchanged |