Skip to content

fix(hooks): detect a pc installed from the retired Homebrew formula - #47

Open
mcdgavin wants to merge 1 commit into
pinecone-io:mainfrom
mcdgavin:fix/hook-detect-formula-install
Open

fix(hooks): detect a pc installed from the retired Homebrew formula#47
mcdgavin wants to merge 1 commit into
pinecone-io:mainfrom
mcdgavin:fix/hook-detect-formula-install

Conversation

@mcdgavin

@mcdgavin mcdgavin commented Sep 9, 2026

Copy link
Copy Markdown

Problem

hooks/pinecone-api-key-check.sh decides whether the Pinecone CLI is installed with command -v pc. The Homebrew formula pinecone-io/tap/pinecone was disabled on 2026-03-30 when the CLI moved to a cask, but a formula installed before then keeps a working pc. Those users read as "installed" every session, so neither they nor Claude hear that the install is stranded, and their next brew upgrade fails on the disabled formula with no warning from the plugin.

This is the gap noted as a follow-up in #46, which fixes the install string itself. The two PRs are independent and touch different hunks of the hook.

Fix

Homebrew links a formula binary into Cellar/ and a cask binary into Caskroom/, so one readlink on the resolved pc path tells them apart:

case "$(readlink "$(command -v pc)" 2>/dev/null)" in
  *Cellar/pinecone/*) cli_via_formula="yes" ;;
  *) cli_via_formula="no" ;;
esac

When a formula install is detected:

  • Agent context gains a note saying the install still runs but is stranded, telling Claude not to interrupt the user for it, and giving the migration command to suggest the next time the CLI comes up: brew uninstall pinecone-io/tap/pinecone && brew install --cask pinecone-io/tap/pinecone.
  • User message gains one clause: "Heads-up: pc came from the retired Homebrew formula; ask Claude how to move it to the cask."

A manual install is not a symlink, readlink prints nothing, and it is treated as a normal install. No new dependencies; readlink is POSIX and Homebrew already assumes it.

Verification

The disabled formula cannot be installed any more, so the formula case is simulated with a temp prefix laid out the way Homebrew does it: prefix/bin/pc -> ../Cellar/pinecone/0.3.1/bin/pc, with the fixture first on PATH.

PATH state installed = Note emitted JSON valid
Simulated formula-linked pc yes yes, in both context and user message yes
Real cask-linked pc on macOS, Homebrew 6.0.22 (/opt/homebrew/Caskroom/pinecone/1.0.1/pc) yes no yes
No pc on PATH no no, existing install guidance unchanged yes

bash -n passes. Output for the cask and absent cases is byte-identical to before.

The session-start hook decides whether the Pinecone CLI is installed with
`command -v pc`. The Homebrew formula pinecone-io/tap/pinecone was disabled
on 2026-03-30 when the CLI moved to a cask, but a pre-existing formula
install keeps a working `pc`, so those users read as "installed" and the
hook never tells them, or Claude, that the install is stranded. Their next
`brew upgrade` fails on the disabled formula with no prior warning.

Homebrew links a formula binary into Cellar/ and a cask binary into
Caskroom/, so one `readlink` on the resolved `pc` path distinguishes them.
When the target contains `Cellar/pinecone/`, the hook adds a note to the
agent context (suggest migrating the next time the CLI comes up; do not
interrupt the user) and a one-line heads-up to the user message. A manual
install is not a symlink, prints nothing, and is treated as fine.

No new dependencies: readlink is in POSIX and already assumed by Homebrew.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant