Skip to content

Semantic search silently disabled when install scripts are blocked (sharp native binary not built) #30

Description

@hernanda-git

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/transformers depends on sharp (native sharp-win32-x64.node binding).
  • 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.ts does await 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

  1. Install Pi, then pi install npm:@samfp/pi-memory in an environment where npm install scripts are blocked.
  2. Start Pi and observe: pi-memory: @xenova/transformers not installed, semantic search disabled.
  3. 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

  1. README / install docs: call out that semantic search needs @xenova/transformers with its native sharp binary built, and that installers which skip postinstall scripts require a manual prebuild-install (or npm install --ignore-scripts=false).
  2. Clearer error: when the import() fails, distinguish "package missing" from "native binary missing / script-blocked", and suggest the prebuild-install fix. 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.

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