librespot icon indicating copy to clipboard operation
librespot copied to clipboard

librespot only outputs version information in certain docker image distributions

Open neekz0r opened this issue 1 year ago • 9 comments

Description

When running in docker, librespot does nothing except output version information.

Version

0.6.0

How to reproduce

Using a similar dockerfile as this, run librespotify:

FROM debian:latest

ENV LIBRESPOT_VERSION="0.6.0"
RUN apt update && \
    apt install -y wget vim pkg-config node-typescript build-essential libasound2-dev rustc curl cargo snapserver procps sox npm && \
    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
    . "$HOME/.cargo/env" && \
    rustup update && \
    mkdir /build && \
    cargo install librespot --version ${LIBRESPOT_VERSION} 
    cp /root/.cargo/bin/librespot /usr/local/bin/

mkdir librespot-test (add the above for docker) docker build . -t librespot-test docker run -it librespot-test

note I stripped down my docker file so as to not annoy developers, but have included the additional required libraries in case there is a conflict. Eg: snapserver, npm, etc.

Log

root@9b5378732238:/# echo "Test standard output"
Test standard output
root@9b5378732238:/# >&2 echo "Test standard error output"
Test standard error output
root@9b5378732238:/# librespot --name TestSpeaker --verbose
librespot 0.6.0 VERGEN_IDEMPOTENT_OUTPUT (Built on 2024-11-29, Build ID: 2wNYHH1X, Profile: release)
root@9b5378732238:/# librespot --cache /var/lib/snapserver --enable-oauth --oauth-port 0 --verbose
librespot 0.6.0 VERGEN_IDEMPOTENT_OUTPUT (Built on 2024-11-29, Build ID: 2wNYHH1X, Profile: release)
root@9b5378732238:/# echo "y u no work?"
y u no work?

Host (what you are running librespot on):

  • OS: Linux (w/ docker) Host: Ubuntu 22.04.4 LTS
  • Docker: Docker version 25.0.4, build 1a576c5
  • Platform: AMD64

Additional context

I'm not 100% sure what the deal is between various distributions, but python:3-alpine (~alpine version 3.20 as of time of writing) works as expected:


ARG LIBRESPOT_VERSION=0.6.0-r0
ARG SNAPCAST_VERSION=0.29.0-r0

RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing/" >> /etc/apk/repositories \
  && echo "https://dl-cdn.alpinelinux.org/alpine/edge/community/" >> /etc/apk/repositories
RUN apk add --no-cache bash snapcast=${SNAPCAST_VERSION} librespot=${LIBRESPOT_VERSION}
RUN pip3 install python-mpd2 musicbrainzngs websocket-client

CMD snapserver

Courtesy of this comment

But this container based on alpine:latest (3.20.3 as of time of writing) exhibits the same behavior:

FROM alpine:latest

ENV LIBRESPOT_VERSION="0.6.0-r0"
ENV SNAPCAST_VERSION="0.29.0-r0"
RUN  echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing/" >> /etc/apk/repositories && \
        echo "https://dl-cdn.alpinelinux.org/alpine/edge/community/" >> /etc/apk/repositories && \
        apk add --no-cache bash snapcast=${SNAPCAST_VERSION} librespot=${LIBRESPOT_VERSION} libid3tag mpd

Finally, I did do an strace on it, but nothing interesting really came up. I'd be more than happy to provide that if thought to be helpful.

Image Works
alpine:3.20.3 :x:
ubuntu:latest :x:
debian:latest :x:
python:3-alpine :white_check_mark:

neekz0r avatar Nov 29 '24 20:11 neekz0r

Can you tell if it's working, just not outputting anything, or hanging after the first print message ?

kingosticks avatar Nov 29 '24 21:11 kingosticks

And can you rule out the docker pid 1 issue?

kingosticks avatar Nov 29 '24 22:11 kingosticks

Can you tell if it's working, just not outputting anything, or hanging after the first print message ?

It is not hanging, nor does it really appear to be outputting anything (other than version info, as above). Strace shows the write to console, and nothing else being written out. It doesn't appear to be opening any sockets anywhere. At the surface level, it appears that running librespot --version provides the exact same behavior as running librespot -n "blah" or librespot --cache /var/lib/snapserver --enable-oauth --oauth-port 0

When I go and run the working image and run strace librespot --cache /var/lib/snapserver --enable-oauth --oauth-port 0 I get expected output and expected writes. On the other images, I get

And can you rule out the docker pid 1 issue?

I am fairly certain that is not what is happening -- in the cases above, I am using bash as the init process, not librespotify or snapcast.

The strace is really small, only a few hundred lines so I've included it as an attachment to help. strace-snapcast.txt

I've also ruled out any sort of memory exhaustion -- there is something like 25G available on the host system.

neekz0r avatar Nov 30 '24 19:11 neekz0r

To.me.that sounds like it is hanging if it's not progressing any further than printing version info. Try running it under gdb?

kingosticks avatar Nov 30 '24 21:11 kingosticks

What I mean by it not "Hanging" is that it immediately exits and does not continue to process anything, to be clear. It happens super fast:

time librespot --cache /var/lib/snapserver --enable-oauth --oauth-port 0
librespot 0.6.0 VERGEN_IDEMPOTENT_OUTPUT (Built on 2024-11-01, Build ID: 1730497895, Profile: release)
real    0m 0.00s
user    0m 0.00s
sys     0m 0.00s

neekz0r avatar Nov 30 '24 21:11 neekz0r

What I mean by it not "Hanging" is that it immediately exits and does not continue to process anything, to be clear. It happens super fast:

time librespot --cache /var/lib/snapserver --enable-oauth --oauth-port 0
librespot 0.6.0 VERGEN_IDEMPOTENT_OUTPUT (Built on 2024-11-01, Build ID: 1730497895, Profile: release)
real    0m 0.00s
user    0m 0.00s
sys     0m 0.00s

Ahh I understand now. Thanks

kingosticks avatar Nov 30 '24 21:11 kingosticks

Have you tried a debug build?

kingosticks avatar Nov 30 '24 21:11 kingosticks

No, just what is available through cargo; to be honest I was kinda expecting this to be some sort of problem exists between keyboard and chair, but I'm begging to think I actually found a bug or something. Hah.

Are you able to duplicate it on your side? That, to me, is the last unknown variable -- is it something to do with my docker host, perhaps? (Although what, I can not fathom!)

neekz0r avatar Nov 30 '24 21:11 neekz0r

I don't have docker on this laptop, I'm really not a fan.

You should be able to use cargo install --debug https://doc.rust-lang.org/cargo/commands/cargo-install.html

kingosticks avatar Nov 30 '24 22:11 kingosticks