[PR #767] [MERGED] fix(deps): move sharp back to optionalDependencies (Termux install regression) #4766

Closed
opened 2026-10-22 04:10:29 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/767
Author: @Romuromylus
Created: 5/12/2026
Status: ✅ Merged
Merged: 5/12/2026
Merged by: @Romuromylus

Base: main ← Head: fix/sharp-revert-to-optional


📝 Commits (1)

  • 1e6a9e9 fix(deps): move sharp back to optionalDependencies

📊 Changes

2 files changed (+5 additions, -5 deletions)

View changed files

📝 packages/server/package.json (+2 -2)
📝 pnpm-lock.yaml (+3 -3)

📄 Description

Linked issue

Closes #746
Refs #735, #758, #737

Why this change

PR #735 moved `sharp` from `optionalDependencies` to `dependencies` as a "semantic correctness" improvement. That turned out to break Termux/Android installs — and this regression was the trigger for the subsequent Termux fixes #737 (wasm32 `.npmrc` injection) and #758 (lazy-load sharp in `game-assets.routes.ts`). Those two helped but did not fully resolve the install-time failure path, because they only mitigate the wasm32-resolved and runtime-load paths respectively.

Timing evidence

  • `11:15Z` — #735 merged.
  • `13:16Z` — issue #746 filed (Termux sharp module load crash).
  • `14:33Z` — #737 merged (wasm32 in `.npmrc`).
  • `16:30Z` — #758 merged (lazy-load sharp).

Why `dependencies` broke Termux

When sharp sits in `dependencies`, pnpm must install it unconditionally. On Android `arm64`:

  1. No `@img/sharp-android-arm64` prebuilt exists.
  2. With the user's prior `.npmrc` (no wasm32 marker — for users who set up before #737), pnpm cannot resolve a platform-matching prebuilt for sharp.
  3. Sharp's install script runs, falls through to a node-gyp source build, and exits non-zero with:
    ```
    sharp: Attempting to build from source via node-gyp
    sharp: Please add node-addon-api to your dependencies
    ELIFECYCLE Command failed with exit code 1.
    ```
  4. Because sharp is no longer optional, the failure is fatal — the entire `pnpm install` bombs. `start-termux.sh`'s auto-rebuild then fails on relaunch.

Sample log (TuGunJr, posting after #758 was merged, on commit `b1204f1`):
```
~/Marinara-Engine $ ./start-termux.sh
...
[WARN] Build commit mismatch: source b1204f1d80 but dist has c408aa7350
[..] Forcing rebuild to apply update...
...
node_modules/.pnpm/sharp@0.34.5/node_modules/sharp: Running install script, failed in 886ms

sharp@0.34.5 build
node install/build.js
sharp: Attempting to build from source via node-gyp
sharp: Please add node-addon-api to your dependencies
ELIFECYCLE Command failed with exit code 1.
```

Note `dist has c408aa7350` — that's the merge commit of #735, confirming this is the post-#735 fallout.

What changed

  • `packages/server/package.json`: move `sharp` from `dependencies` back to `optionalDependencies`. Restores the pre-#735 state for this manifest field.
  • `pnpm-lock.yaml`: regenerated to reflect sharp's restored section.

The `Dockerfile.lite` changes from #735 (drop `--no-optional`, add `pnpm rebuild sharp`, explicit `rm -rf onnxruntime-{node,web}`) stay in place — they fixed the original Lite startup crash from issue #734 independently of where sharp sits in `package.json`. Because Dockerfile.lite no longer passes `--no-optional`, sharp is installed in the Lite image either way.

Validation

  • `pnpm check` passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed `CONTRIBUTING.md`

Manual verification notes

Still needs human verification:

  • Manually verify on Termux (Android arm64) that `./start-termux.sh` completes pnpm install without ELIFECYCLE — both with a fresh checkout and with a stale `.npmrc` from before #737.
  • Manually verify the regular `Dockerfile` still builds and runs (the manifest move is intended to be a no-op there since it has no `--no-optional` flag).
  • Manually verify `Dockerfile.lite` still builds and runs after this revert (sharp should still be installed because `--no-optional` is no longer passed). I'll rebuild the Lite image on a clean amd64 Linux host as a side-check; will note the result here once it lands.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

N/A — `package.json` manifest revert + lockfile regenerate.

Summary by CodeRabbit

  • Chores
    • Reorganized server dependencies to reduce core installation requirements. The sharp package is now optional, allowing users to install only the components they need.

Review Change Stack


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/767 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 5/12/2026 **Status:** ✅ Merged **Merged:** 5/12/2026 **Merged by:** [@Romuromylus](https://github.com/Romuromylus) **Base:** `main` ← **Head:** `fix/sharp-revert-to-optional` --- ### 📝 Commits (1) - [`1e6a9e9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1e6a9e940eecc3798cec09f206dfaf5a0732f7e6) fix(deps): move sharp back to optionalDependencies ### 📊 Changes **2 files changed** (+5 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/package.json` (+2 -2) 📝 `pnpm-lock.yaml` (+3 -3) </details> ### 📄 Description ## Linked issue Closes #746 Refs #735, #758, #737 ## Why this change PR #735 moved \`sharp\` from \`optionalDependencies\` to \`dependencies\` as a "semantic correctness" improvement. That turned out to break Termux/Android installs — and this regression was the trigger for the subsequent Termux fixes #737 (wasm32 \`.npmrc\` injection) and #758 (lazy-load sharp in \`game-assets.routes.ts\`). Those two helped but did not fully resolve the install-time failure path, because they only mitigate the wasm32-resolved and runtime-load paths respectively. **Timing evidence** - \`11:15Z\` — #735 merged. - \`13:16Z\` — issue #746 filed (Termux sharp module load crash). - \`14:33Z\` — #737 merged (wasm32 in \`.npmrc\`). - \`16:30Z\` — #758 merged (lazy-load sharp). **Why \`dependencies\` broke Termux** When sharp sits in \`dependencies\`, pnpm must install it unconditionally. On Android \`arm64\`: 1. No \`@img/sharp-android-arm64\` prebuilt exists. 2. With the user's prior \`.npmrc\` (no wasm32 marker — for users who set up before #737), pnpm cannot resolve a platform-matching prebuilt for sharp. 3. Sharp's install script runs, falls through to a node-gyp source build, and exits non-zero with: \`\`\` sharp: Attempting to build from source via node-gyp sharp: Please add node-addon-api to your dependencies ELIFECYCLE Command failed with exit code 1. \`\`\` 4. Because sharp is no longer optional, the failure is fatal — the entire \`pnpm install\` bombs. \`start-termux.sh\`'s auto-rebuild then fails on relaunch. Sample log (TuGunJr, posting after #758 was merged, on commit \`b1204f1\`): \`\`\` ~/Marinara-Engine $ ./start-termux.sh ... [WARN] Build commit mismatch: source b1204f1d80a8 but dist has c408aa735054 [..] Forcing rebuild to apply update... ... node_modules/.pnpm/sharp@0.34.5/node_modules/sharp: Running install script, failed in 886ms > sharp@0.34.5 build > node install/build.js sharp: Attempting to build from source via node-gyp sharp: Please add node-addon-api to your dependencies ELIFECYCLE Command failed with exit code 1. \`\`\` Note \`dist has c408aa735054\` — that's the merge commit of #735, confirming this is the post-#735 fallout. ## What changed - \`packages/server/package.json\`: move \`sharp\` from \`dependencies\` back to \`optionalDependencies\`. Restores the pre-#735 state for this manifest field. - \`pnpm-lock.yaml\`: regenerated to reflect sharp's restored section. The \`Dockerfile.lite\` changes from #735 (drop \`--no-optional\`, add \`pnpm rebuild sharp\`, explicit \`rm -rf onnxruntime-{node,web}\`) **stay in place** — they fixed the original Lite startup crash from issue #734 independently of where sharp sits in \`package.json\`. Because Dockerfile.lite no longer passes \`--no-optional\`, sharp is installed in the Lite image either way. ## Validation - [x] \`pnpm check\` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed \`CONTRIBUTING.md\` ### Manual verification notes Still needs human verification: - Manually verify on Termux (Android arm64) that \`./start-termux.sh\` completes pnpm install without ELIFECYCLE — both with a fresh checkout and with a stale \`.npmrc\` from before #737. - Manually verify the regular \`Dockerfile\` still builds and runs (the manifest move is intended to be a no-op there since it has no \`--no-optional\` flag). - Manually verify \`Dockerfile.lite\` still builds and runs after this revert (sharp should still be installed because \`--no-optional\` is no longer passed). I'll rebuild the Lite image on a clean amd64 Linux host as a side-check; will note the result here once it lands. ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) N/A — \`package.json\` manifest revert + lockfile regenerate. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Reorganized server dependencies to reduce core installation requirements. The `sharp` package is now optional, allowing users to install only the components they need. [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/767) <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:10:29 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4766
No description provided.