From f1162ed4a4960d84f71c21db3da6ba0cf4707c55 Mon Sep 17 00:00:00 2001 From: Alex Newman Date: Mon, 16 Feb 2026 19:20:34 -0500 Subject: [PATCH] fix: remove sharp dependency that was never needed (#1141) Sharp was an explicit dependency but nothing in the codebase imports it. Chroma embeddings use ONNX Runtime via @chroma-core/default-embed, not sharp. Sharp's native binary has a persistent Bun node_modules layout bug where @img/sharp-libvips-* isn't placed alongside @img/sharp-darwin-* causing ERR_DLOPEN_FAILED on every install. - Remove sharp, @img/sharp-libvips-darwin-arm64, node-gyp from deps - Remove node-addon-api from devDeps - Remove @img cache clearing hacks from smart-install.js and sync-marketplace.cjs - Replace with simple `bun pm cache rm` before install as general cache hygiene Co-authored-by: Claude Opus 4.6 --- package.json | 1 - scripts/smart-install.js | 19 +++++++++---------- scripts/sync-marketplace.cjs | 22 ++++++---------------- 3 files changed, 15 insertions(+), 27 deletions(-) diff --git a/package.json b/package.json index 18f67bb7..9d194816 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,6 @@ "@types/react": "^18.3.5", "@types/react-dom": "^18.3.0", "esbuild": "^0.27.2", - "node-addon-api": "^8.5.0", "np": "^11.0.2", "tsx": "^4.20.6", "typescript": "^5.3.0" diff --git a/scripts/smart-install.js b/scripts/smart-install.js index eb93aa8c..2e429798 100644 --- a/scripts/smart-install.js +++ b/scripts/smart-install.js @@ -5,7 +5,7 @@ * Ensures Bun runtime and uv (Python package manager) are installed * (auto-installs if missing) and handles dependency installation when needed. */ -import { existsSync, readFileSync, writeFileSync, rmSync } from 'fs'; +import { existsSync, readFileSync, writeFileSync } from 'fs'; import { execSync, spawnSync } from 'child_process'; import { join } from 'path'; import { homedir } from 'os'; @@ -260,18 +260,17 @@ function installDeps() { console.error('📦 Installing dependencies with Bun...'); - // Clear stale native module cache (sharp/libvips) to prevent broken dylib references. - // Bun's cache can retain native binaries that reference companion libraries at - // broken relative paths after version upgrades. - const bunCacheImgDir = join(homedir(), '.bun', 'install', 'cache', '@img'); - if (existsSync(bunCacheImgDir)) { - console.error(' Clearing stale native module cache (@img/sharp)...'); - rmSync(bunCacheImgDir, { recursive: true, force: true }); - } - // Quote path for Windows paths with spaces const bunCmd = IS_WINDOWS && bunPath.includes(' ') ? `"${bunPath}"` : bunPath; + // Clear Bun's package cache to prevent stale native module artifacts + try { + execSync(`${bunCmd} pm cache rm`, { cwd: ROOT, stdio: 'pipe', shell: IS_WINDOWS }); + console.error(' Cleared Bun package cache'); + } catch { + // Cache may not exist yet on first install + } + execSync(`${bunCmd} install`, { cwd: ROOT, stdio: 'inherit', shell: IS_WINDOWS }); // Write version marker diff --git a/scripts/sync-marketplace.cjs b/scripts/sync-marketplace.cjs index c7b325d0..190dcc23 100644 --- a/scripts/sync-marketplace.cjs +++ b/scripts/sync-marketplace.cjs @@ -80,22 +80,12 @@ try { { stdio: 'inherit' } ); - // Remove stale lockfiles before install — they pin old native dep versions - const { unlinkSync, rmSync } = require('fs'); - for (const lockfile of ['package-lock.json', 'bun.lock']) { - const lockpath = path.join(INSTALLED_PATH, lockfile); - if (existsSync(lockpath)) { - unlinkSync(lockpath); - console.log(`Removed stale ${lockfile}`); - } - } - - // Clear stale native module cache (sharp/libvips) — Bun's cache can retain - // native binaries that reference companion libraries at broken relative paths - const bunCacheImgDir = path.join(os.homedir(), '.bun', 'install', 'cache', '@img'); - if (existsSync(bunCacheImgDir)) { - rmSync(bunCacheImgDir, { recursive: true, force: true }); - console.log('Cleared stale native module cache (@img/sharp)'); + // Clear Bun's package cache to prevent stale native module artifacts + try { + execSync('bun pm cache rm', { cwd: INSTALLED_PATH, stdio: 'pipe' }); + console.log('Cleared Bun package cache'); + } catch { + // Cache may not exist yet on first install } console.log('Running bun install in marketplace...');