webtorrent / webtorrent-cli

WebTorrent, the streaming torrent client. For the command line.
https://webtorrent.io
MIT License
1.16k stars 133 forks source link

Can't install webtorrent-cli in npm #313

Open asimovc opened 3 months ago

asimovc commented 3 months ago

What version of this package are you using? npm version

What operating system, Node.js, and npm version? OS: Kiss Linux (musl and busybox based distro) Node.js: v22.3.0 Npm: v10.8.1

What happened? Can't install webtorrent-cli with `npm install webtorrent-cli -g

`What did you expect to happen? Installation complete of webtorrent-cli

Are you willing to submit a pull request to fix this bug? No

asimovc commented 3 months ago

Here some logs

SilentBot1 commented 3 months ago

Hey @asimovc,

WebTorrent >= 2.3.0 now has WebRTC support, provided by the dependency node-datachannel.

node-datachannel provides prebuilds of libdatachannel (the underlying native library) for all officially supported versions of NodeJS, but the musl version of NodeJS is considered unofficial, and is not currently provided.

If you wish to use webtorrent>=2.3.0 or webtorrent-cli>=5.0.0 on musl, you must install the build requirements for libdatachannel, which can be done by running the following command: apk add build-base cmake git openssl-libs-static openssl-dev.

Alternatively, you can downgrade webtorrent to <2.3.0 or webtorrent-cli to <5.0.0, though from my little testing, the utp-native dependency also appears to cause issues and is segfaulting currently.

We're investigating whether we can help node-datachannel provide a pre-built version of libdatachannel for musl so you do not need to install and build this locally and also fix any outstanding issues with utp-native, though as we don't officially support musl, this is not a priority from our side unfortunately.

asimovc commented 3 months ago

I have cmake 3.29.5-1, openssl 3.3.1-1 and git 2.45.2-1

SilentBot1 commented 3 months ago

Hi @asimovc,

The error specifically in your build appears to be:

1623 error /home/hellboy/.npm/lib/node_modules/webtorrent-cli/node_modules/node-datachannel/build/_deps/libdatachannel-src/src/h264rtpdepacketizer.cpp: In member function 'virtual void rtc::H264RtpDepacketizer::incoming(rtc::message_vector&, const rtc::message_callback&)':
1623 error /home/hellboy/.npm/lib/node_modules/webtorrent-cli/node_modules/node-datachannel/build/_deps/libdatachannel-src/src/h264rtpdepacketizer.cpp:116:29: error: 'remove_if' is not a member of 'std'; did you mean 'remove_cv'?
1623 error   116 |         messages.erase(std::remove_if(messages.begin(), messages.end(),
1623 error       |                             ^~~~~~~~~
1623 error       |                             remove_cv

This appears to relate to the issue https://github.com/paullouisageneau/libdatachannel/issues/1173 on libdatachannel, but this was fixed in May in this PR: https://github.com/paullouisageneau/libdatachannel/pull/1183

From a fresh alpine container, I can successfully install webtorrent-cli as seen below, with the exact above dependencies: image

Can you clear out anything you have cached, and try this again?

Note: Even outside of libdatachannel not building successfully, utp-native appears to cause a segfault on musl, so will almost always crash webtorrent-cli, this is due to utp-native installing the glibc native dependency (as there is no musl build). I have created a PR here which adds musl support to utp-native, and should prevent the wrong libc from being used.

asimovc commented 3 months ago

I cleared my _ccache in node install dir and still not build

SilentBot1 commented 3 months ago

I've made a PR here (along with @funniray) which adds musl prebuilds for libdatachannel to node-datachannel, which should remove the requirement for you to need to build this locally once implemented.

asimovc commented 3 months ago

@SilentBot1 Thanks i also made a issue about the version, i seems node-datachannel is not in the latest version of libdatachannel that's why i get these failed build

asimovc commented 3 months ago

@SilentBot1 node-datachannel already made a PR that builds fine in musl, please update the dependencies version

SilentBot1 commented 3 months ago

I'm aware @asimovc, It was my PR https://github.com/murat-dogan/node-datachannel/pull/264.

I will update the dependency once they fix OSX builds, which are currently not building.

SilentBot1 commented 1 month ago

Just to provide an update, you should now be able to install this app on Alpine / musl-based systems, but utp-native will still throw a segfault due to not having musl builds as this pr has not been merged/reviewed.