Streamlink fails to run when using certain wrapper scripts
See original GitHub issueBug report
- I understand the difference between Streamlink and Streamlink Twitch GUI.
- This is a bug report and I have read the contribution guidelines.
Environment details
Operating system and version:
NixOS 19.09
Streamlink Twitch GUI version:
1.9.1
Streamlink version:
1.3.1
Description
I’m attempting to write a Nix derivation for streamlink-twitch-gui, and having an issue with the automatic handling of wrapper scripts. I’m not sure if this may be an issue with the shebang type being different on NixOS or a different problem, but either way streamlink-twitch-gui refuses to run the script unless I manually set the path to the “unwrapped” binary in the settings. For reference, here is the wrapper script:
#! /nix/store/kgp3vq8l9yb8mzghbw83kyr3f26yqvsz-bash-4.4-p23/bin/bash -e
export PATH='/nix/store/syqcp8zb9c0vxj2sx6jbv5f9q7yki4jz-python3-3.7.7/bin:/nix/store/7lc2j0zxq6hakf89swr08a6jvdnmvk24-streamlink-1.3.1/bin:/nix/store/wyvzykym54601iry33v05hzp864cbqzi-python3.7-chardet-3.0.4/bin:/nix/store/qfi1h97flkdax6ag0n0aj7545xcivr5g-python3.7-setuptools-45.2.0/bin:/nix/store/n8nw2xs2q4vk8ybd0yj3f333fr74ixdd-python3.7-websocket_client-0.56.0/bin:/nix/store/kc74iz3k6j67vr2lxfdrj2m3ww5hd1qh-openssl-1.1.1f-bin/bin:/nix/store/ybv5a5mbalj3791l1w3v2jy452n58vf1-rtmpdump-2019-03-30/bin:/nix/store/2sfcwvmmg3pj4pyqgf81ikf1l6jbn41c-ffmpeg-3.4.7-bin/bin'${PATH:+':'}$PATH
export PYTHONNOUSERSITE='true'
exec -a "$0" "/nix/store/7lc2j0zxq6hakf89swr08a6jvdnmvk24-streamlink-1.3.1/bin/.streamlink-wrapped" "$@"
Setting the path to “.streamlink-wrapped” manually in the settings fixes it temporarily, but is an annoying workaround since the built derivation path for streamlink will change with updates.
Expected / Actual behavior
I expect streamlink-twitch-gui to be able to use the wrapper script as expected, and run streamlink.
Reproduction steps
- Use the nix derivation I’ve created (see here for the current state).
- Run the built derivation binary and attempt to launch a stream.
- Get the error.
Log output
[error][StreamingService]
ProviderError: Couldn't validate python script
Executables were not found
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)

Top Related StackOverflow Question
Hi! Sorry this took me so long to get back around to, I unfortunately haven’t had much luck getting the yarn build to work (the node ecosystem is still a bit difficult to work with on NixOS) but this will make packaging the binary releases work much better. I just tested it and the new release works great! Thanks so much for your help 😄
Just a quick note regarding the streaming provider config: I guess the unnecessary complexity with the custom python module script resolver can be removed, as it’s not necessary anymore. I will see if I can rewrite the resolver config to a simpler one this weekend, which should make patching custom stuff required by packages like this much easier. Most causes of the notorious “invalid version string output” error will also be fixed by that, as there won’t be room for invalid python path configs.
To explain this a bit more in detail, the Streamlink python and python script resolver had to be implemented in the past due to an issue on Windows related to the Streamlink launcher file, as it had the wrong python executable hardcoded, which caused it to always spawn a terminal window, which was unacceptable for the Twitch GUI. The system-independent solution was to find Streamlink’s python entry module script file and get the path of the python executable from its shebang at the top and replace the executable name with the proper one on Windows and launch python with the module script as first parameter. An additional step also had to be implemented for macOS’s homebrew package, as it uses a BASH script wrapper to set an additional python env var. This is where the wrapper script “support” comes from.
Since my pull request with a fix got merged last year into Streamlink’s Windows installer dependency
pynsist, this resolver workaround wasn’t needed anymore, as there were two separate Streamlink launchers now, and the additional “streamlinkw” resolver config as added. It was basically the same as the old Livestreamer resolver config, because Livestreamer never had this problem. It got removed a few months later though, as it became fully incompatible with Twitch.The remnants of this whole nonsense is the current situation with two separate resolver configs, one of them being a workaround that isn’t needed anymore but works fine (except for situations as described in this thread) and one resolver config for Windows which would also work on all OSes, but only has Windows related data set.