Skip to content

fix(packaging): sharp missing from optionalDependencies — image attachment processing fails on fresh install #83401

@scotthuang

Description

@scotthuang

Summary

Fresh npm i -g openclaw does not install sharp, causing browser screenshot image resize and media-understanding image ops to fail with:

Optional dependency sharp is required for image attachment processing

Root Cause

extensions/media-understanding-core/image-ops.ts:57 dynamically imports sharp and throws when it's missing. However, sharp is not declared in package.json under dependencies, optionalDependencies, or peerDependencies. So npm install never installs it.

Users currently have to manually run:

SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm i sharp@0.34.5 --no-save --prefix $(dirname $(realpath $(which openclaw)))/..

Suggested Fix

Add sharp to optionalDependencies in root package.json:

 "optionalDependencies": {
+  "sharp": "^0.34.5",
   "sqlite-vec": "0.1.9"
 }

Using optionalDependencies (not dependencies) because:

  • sharp has native bindings that can fail to build on some platforms (Homebrew libvips conflicts, musl, etc.)
  • The codebase already handles the missing-sharp case gracefully with a clear error message
  • This matches the existing pattern used for sqlite-vec

Environment

  • OpenClaw 2026.5.16-beta.6
  • macOS, Node 22
  • Affects: browser screenshot resize, media-understanding image ops, any path through extensions/media-understanding-core/image-ops.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions