pi-memory
pi-memory copied to clipboard
Semantic search silently disabled when install scripts are blocked (sharp native binary not built)
Summary
When @xenova/transformers is installed via a tool that blocks npm lifecycle scripts (e.g. npm with allowScripts disabled, or Pi's bundled installer which skips postinstall by default), semantic search is silently disabled with no actionable guidance.
Root cause
@xenova/transformersdepends onsharp(nativesharp-win32-x64.nodebinding).sharp's install script (install/libvips+ prebuilt binary fetch) is what produces that binding. If lifecycle scripts are skipped, the binding is absent.src/embedder.tsdoesawait import("@xenova/transformers")and on any throw prints:pi-memory: @xenova/transformers not installed, semantic search disabled- The actual underlying error is a missing native module (
Cannot find module '../build/Release/sharp-win32-x64.node'), not "transformers not installed". Users (and the agent running the install) are misled into thinking the package is simply absent.
Reproduction
- Install Pi, then
pi install npm:@samfp/pi-memoryin an environment where npm install scripts are blocked. - Start Pi and observe:
pi-memory: @xenova/transformers not installed, semantic search disabled. node -e "import('@xenova/transformers')"→Cannot find module '../build/Release/sharp-win32-x64.node'.
Workaround (verified)
Inside the package dir, run npx prebuild-install (or node install/libvips + prebuild-install) so the prebuilt sharp binary is fetched; the import() then succeeds.
Suggested doc/UX improvements
- README / install docs: call out that semantic search needs
@xenova/transformerswith its nativesharpbinary built, and that installers which skip postinstall scripts require a manualprebuild-install(ornpm install --ignore-scripts=false). - Clearer error: when the
import()fails, distinguish "package missing" from "native binary missing / script-blocked", and suggest theprebuild-installfix. This would have saved significant debugging time.
Semantic search itself works great once the native binary is present — this is purely a discoverability/install-friction issue.
Happy to PR a README note and/or a refined error message if you'd like.