โ† Back to PRs

#23337: fix: move @discordjs/opus to optionalDependencies [AI-assisted ๐Ÿค–]

by davidmckenzie open 2026-02-22 06:59 View on GitHub โ†’
size: XS
## Summary - Problem: `npm install -g openclaw@latest` fails on x64/ARM/Docker with `EBUILDNOSUPPORT: No prebuilt binaries found for @discordjs/opus` - Why it matters: Blocks clean installs on all common platforms (Linux x64, ARM, Docker) for users not using Discord voice features - What changed: `@discordjs/opus` moved from `dependencies` โ†’ `optionalDependencies` in `package.json` (1 line removed, 3 added) - What did NOT change: Discord voice functionality is unaffected on platforms where a prebuilt binary exists; all other dependencies unchanged ## Change Type (select all) - [x] Bug fix ## Scope (select all touched areas) - [x] CI/CD / infra ## Linked Issue/PR - Closes #22877 ## User-visible / Behavior Changes `npm install -g openclaw@latest` (and `pnpm install`) now succeeds on platforms without a prebuilt `@discordjs/opus` binary. Discord voice continues to work where binaries are available. ## Security Impact (required) - New permissions/capabilities? No - Secrets/tokens handling changed? No - New/changed network calls? No - Command/tool execution surface changed? No - Data access scope changed? No ## Repro + Verification ### Environment - OS: Linux x64 (Docker, WSL2) - Runtime/container: Node 22, Docker multi-stage build - Model/provider: N/A - Integration/channel: N/A ### Steps 1. `npm install -g openclaw@latest` on a clean x64/ARM/Docker environment 2. Observe `EBUILDNOSUPPORT: No prebuilt binaries found for @discordjs/opus` 3. With this fix applied, install completes successfully ### Expected Install completes without error ### Actual (before fix) `EBUILDNOSUPPORT: No prebuilt binaries found for @discordjs/opus` ## Evidence - [x] Trace/log snippets `pnpm install` with fix applied: ``` โ•ญ Warning โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”‚ Ignored build scripts: @discordjs/opus. โ”‚ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ Done in 36.3s using pnpm v10.23.0 ``` `require('@discordjs/opus')` โ€” graceful runtime failure (no install abort): ``` Error: Cannot find module '...prebuild/node-v127-napi-v3-linux-x64-glibc-2.36/opus.node' ``` openclaw loads clean without opus: ``` import('./dist/index.js') โ†’ loads ok โœ… ``` - `pnpm build` โœ… `pnpm check` โœ… (format, typecheck, lint all clean) - `src/plugins/tools.optional.test.ts` โ€” 5/5 โœ… - AI-assisted: built with Claude (running inside OpenClaw/Canopy). Prompts available on request. - Degree of testing: lightly tested (unit + build + lint; full suite skipped โ€” metadata-only change, CI will cover) ## Human Verification (required) Verified on: Linux x64, Node v22.22.0, Docker (WSL2) - `pnpm install` completed โ€” opus build scripts skipped (confirmed via pnpm warning) - No prebuilt binary present (`opus.node` missing for `node-v127-napi-v3-linux-x64-glibc-2.36`) - `require('@discordjs/opus')` produces graceful runtime `MODULE_NOT_FOUND` โ€” install-time failure eliminated - `import('./dist/index.js')` โ†’ `loads ok โœ…` โ€” openclaw runs without opus present - Did NOT verify: ARM build, Discord voice on a platform with a valid prebuilt binary To add: this seems like a low enough risk change with high reward to fix builds that are reported on multiple envs, I don't have the full development environment set up to test fully end to end, but I'm hoping contextually that's not an issue :) ## Compatibility / Migration - Backward compatible? Yes - Config/env changes? No - Migration needed? No ## Failure Recovery (if this breaks) - Revert: restore `@discordjs/opus` to `dependencies`, remove from `optionalDependencies` in `package.json` - Known bad symptoms: Discord voice features unavailable on affected platforms (but those were already broken before this fix at install time) ## Risks and Mitigations - Risk: platforms that previously failed loudly at install now silently skip opus - Mitigation: Discord voice will fail at runtime with a clear missing-module error if used โ€” same outcome, shifted from install-time to runtime <!-- greptile_comment --> <h3>Greptile Summary</h3> Moved `@discordjs/opus` from `dependencies` to `optionalDependencies` to fix install failures on platforms without prebuilt binaries (x64/ARM/Docker). The change is safe because: - Discord voice code already implements a fallback chain: `opusscript` (primary, still in dependencies) โ†’ `@discordjs/opus` (secondary, now optional) โ†’ graceful degradation - `createOpusDecoder()` in `src/discord/voice/manager.ts:149-170` handles missing decoders by returning `null`, which is checked before use - Users without Discord voice features are unaffected; users with voice continue working via `opusscript` or where `@discordjs/opus` binaries are available <h3>Confidence Score: 5/5</h3> - Safe to merge - fixes install failures without breaking Discord voice functionality - The change is a minimal, well-targeted fix with existing fallback mechanisms. The code already handles missing opus decoders gracefully via opusscript (which remains in dependencies), and the PR addresses a real blocking issue affecting multiple platforms. - No files require special attention <sub>Last reviewed commit: 8321db3</sub> <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs