discordx-ts / discordx

🤖 Create a discord bot with TypeScript and Decorators!
https://discordx.js.org
Apache License 2.0
625 stars 50 forks source link

[Bug]: @discordjs/opus incompatible package version with arm64 architecture #650

Closed PoulpY2K closed 2 years ago

PoulpY2K commented 2 years ago

What happened?

After setting up my new dev environment on my Apple Mac M1, I cloned my project which uses @discordx. When I tried to run npm install, I got an error caused by @discordjs/opus. After looking deeper into it, I found out that @discordx/music uses @discordjs/opus@0.5.3 and support for ARM64 architecture only happens in @discordjs/opus@0.6.0.

It breaks the whole installation and can only be resolved by forcing the install of @discordjs/opus@0.6.0 inside my own project.

@discordjs/opus release page

image

I'm currently writing the PR to fix this issue.

Reproduction

ONLY REPRODUCIBLE ON MACOS M1 (ARM64)

1 - Install discordx via the create-discordx package.

2 - CD into the project

3 - Run npm i @discordx/music

Package

@discordx/music

Version

Stable

Relevant log output

npm ERR! code 1
npm ERR! path /Users/poulpy2k/ghq/github.com/PoulpY2K/my-app/node_modules/@discordjs/opus
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build
npm ERR! CC(target) Release/obj.target/libopus/deps/opus/src/opus_multistream.o
npm ERR!   CC(target) Release/obj.target/libopus/deps/opus/src/opus_projection_encoder.o
npm ERR!   CC(target) Release/obj.target/libopus/deps/opus/src/analysis.o
npm ERR!   CC(target) Release/obj.target/libopus/deps/opus/src/mlp_data.o
npm ERR!   CC(target) Release/obj.target/libopus/deps/opus/src/opus_multistream_encoder.o
npm ERR!   CC(target) Release/obj.target/libopus/deps/opus/src/opus_projection_decoder.o
npm ERR!   CC(target) Release/obj.target/libopus/deps/opus/src/mapping_matrix.o
npm ERR!   CC(target) Release/obj.target/libopus/deps/opus/src/opus_compare.o
npm ERR!   CC(target) Release/obj.target/libopus/deps/opus/src/mlp.o
npm ERR!   CC(target) Release/obj.target/libopus/deps/opus/src/opus.o
npm ERR!   CC(target) Release/obj.target/libopus/deps/opus/src/opus_multistream_decoder.o
npm ERR!   CC(target) Release/obj.target/libopus/deps/opus/src/opus_decoder.o
npm ERR! Failed to execute '/opt/homebrew/Cellar/node/17.9.0/bin/node /opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/poulpy2k/ghq/github.com/PoulpY2K/my-app/node_modules/@discordjs/opus/prebuild/node-v102-napi-v3-darwin-arm64-unknown-unknown/opus.node --module_name=opus --module_path=/Users/poulpy2k/ghq/github.com/PoulpY2K/my-app/node_modules/@discordjs/opus/prebuild/node-v102-napi-v3-darwin-arm64-unknown-unknown --napi_version=8 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using node-pre-gyp@0.4.2
npm ERR! node-pre-gyp info using node@17.9.0 | darwin | arm64
npm ERR! node-pre-gyp info check checked for "/Users/poulpy2k/ghq/github.com/PoulpY2K/my-app/node_modules/@discordjs/opus/prebuild/node-v102-napi-v3-darwin-arm64-unknown-unknown/opus.node" (not found)
npm ERR! node-pre-gyp http GET https://github.com/discordjs/opus/releases/download/v0.5.3/opus-v0.5.3-node-v102-napi-v3-darwin-arm64-unknown-unknown.tar.gz
npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/discordjs/opus/releases/download/v0.5.3/opus-v0.5.3-node-v102-napi-v3-darwin-arm64-unknown-unknown.tar.gz 
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for @discordjs/opus@0.5.3 and node@17.9.0 (node-v102 ABI, unknown) (falling back to source compile with node-gyp) 
npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/discordjs/opus/releases/download/v0.5.3/opus-v0.5.3-node-v102-napi-v3-darwin-arm64-unknown-unknown.tar.gz 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.0.0
npm ERR! gyp info using node@17.9.0 | darwin | arm64
npm ERR! gyp info ok 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.0.0
npm ERR! gyp info using node@17.9.0 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.10.2 found at "/opt/homebrew/opt/python@3.10/bin/python3.10"
npm ERR! gyp info spawn /opt/homebrew/opt/python@3.10/bin/python3.10
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/poulpy2k/ghq/github.com/PoulpY2K/my-app/node_modules/@discordjs/opus/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/poulpy2k/Library/Caches/node-gyp/17.9.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/Users/poulpy2k/Library/Caches/node-gyp/17.9.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/poulpy2k/Library/Caches/node-gyp/17.9.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/poulpy2k/ghq/github.com/PoulpY2K/my-app/node_modules/@discordjs/opus',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info ok 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.0.0
npm ERR! gyp info using node@17.9.0 | darwin | arm64
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../deps/opus/src/opus_decoder.c:50:
npm ERR! In file included from ../deps/opus/silk/structs.h:32:
npm ERR! In file included from ../deps/opus/silk/SigProc_FIX.h:51:
npm ERR! ../deps/opus/silk/arm/biquad_alt_arm.h:31:11: fatal error: 'celt/arm/armcpu.h' file not found
npm ERR! # include "celt/arm/armcpu.h"
npm ERR!           ^~~~~~~~~~~~~~~~~~~
npm ERR! 1 error generated.
npm ERR! make: *** [Release/obj.target/libopus/deps/opus/src/opus_decoder.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Darwin 21.4.0
npm ERR! gyp ERR! command "/opt/homebrew/Cellar/node/17.9.0/bin/node" "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/poulpy2k/ghq/github.com/PoulpY2K/my-app/node_modules/@discordjs/opus/prebuild/node-v102-napi-v3-darwin-arm64-unknown-unknown/opus.node" "--module_name=opus" "--module_path=/Users/poulpy2k/ghq/github.com/PoulpY2K/my-app/node_modules/@discordjs/opus/prebuild/node-v102-napi-v3-darwin-arm64-unknown-unknown" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3"
npm ERR! gyp ERR! cwd /Users/poulpy2k/ghq/github.com/PoulpY2K/my-app/node_modules/@discordjs/opus
npm ERR! gyp ERR! node -v v17.9.0
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok 
npm ERR! node-pre-gyp ERR! build error 
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/opt/homebrew/Cellar/node/17.9.0/bin/node /opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/poulpy2k/ghq/github.com/PoulpY2K/my-app/node_modules/@discordjs/opus/prebuild/node-v102-napi-v3-darwin-arm64-unknown-unknown/opus.node --module_name=opus --module_path=/Users/poulpy2k/ghq/github.com/PoulpY2K/my-app/node_modules/@discordjs/opus/prebuild/node-v102-napi-v3-darwin-arm64-unknown-unknown --napi_version=8 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/poulpy2k/ghq/github.com/PoulpY2K/my-app/node_modules/@discordjs/node-pre-gyp/lib/util/compile.js:85:20)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1090:16)
npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
npm ERR! node-pre-gyp ERR! System Darwin 21.4.0
npm ERR! node-pre-gyp ERR! command "/opt/homebrew/Cellar/node/17.9.0/bin/node" "/Users/poulpy2k/ghq/github.com/PoulpY2K/my-app/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd /Users/poulpy2k/ghq/github.com/PoulpY2K/my-app/node_modules/@discordjs/opus
npm ERR! node-pre-gyp ERR! node -v v17.9.0
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v0.4.2
npm ERR! node-pre-gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/poulpy2k/.npm/_logs/2022-04-24T10_35_38_120Z-debug-0.log

Code of Conduct

vijayymmeena commented 2 years ago

djs opus is peer dep, so install opus and voice first, then install discordx music

vijayymmeena commented 2 years ago

if you are not in our discord server, please join and ask for support in it. it's fast and easier to chat there.

PoulpY2K commented 2 years ago

After discussing it on Discord, this is not a discordx problem.

Maybe it would be a good thing to add a small line in the discordx/music README to tell mac M1 users to specifically install the discordjs/opus@0.6.0 version before discordx/music.

Thank you for you time and answer !