Snapcraft issues with Alsa via pygame

Hi @Bala .

Add this in your *.yaml file, and try again.

apps:
    white-canary:
        environment:
            LD_LIBRARY_PATH: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio:$LD_LIBRARY_PATH




1 Like

ALSA is a mess in snaps.

There’s a few ways to do it. @James-Carroll posted their solution a while back. Give that a try.

1 Like

Do not hesitate to try this too :

Add this your python script .


import os
os.environ['SDL_AUDIODRIVER'] = 'dsp'
import pygame

Why? What is the goal of this?

@popey , this variable allows to specify the audio driver that SDL (the library used by pygame to manage audio) should use.

By setting this environment variable, we might be able to work around some ALSA issues by telling SDL to use a different audio driver.

Ok, but dsp is quite probably the worst option to choose, isn’t it?

@popey , pulse is also an alternative :blush:.

The dsp driver is the default audio driver for Unix systems.

Ok, well let’s try and give people useful responses rather than random technology suggestions from 30 years ago, please. :skull:

Hmm ! @popey :blush:.

The goal in itself is that it works.

Afterwards we can vary according to our preferences.

No one is omniscient, I am here mainly to learn (in theory and in practice) :beginner:.

Right, but I keep seeing what looks like either chat-gpt or random googling in responses to technical questions from you.

This leads people down the wrong path. If you have a solid answer which helps to resolve the question, then by all means answer the question. But if you pluck a random environment variable to select audio technology from the previous century, when we’ve all moved on from OSS through ALSA to Pulse and now Pipewire, the user is going to have a bad day. So please, can we try and post more researched and authoritative answers, not wild guesses?

@popey ! One of the most desired wishes of a humain being aspiring to rational purity is to be perpetually in power.

As a French-speaking person, if I had thought that my words and writings should accurately reflect the depths of my thoughts and my soul, I would never express myself or write in English. However, I persevere in writing and speaking in English, because I am firmly convinced that it greatly contributes to my personal enrichment.

Not all answers may come from documented official sources or anything of that nature.
Moreover, there have never been any solutions that have become state-proven without rigorous testing. And yes, I sometimes use all the tools available that have proven their worth before making certain proposals or suggestions, and I am very happy about that.

Once again, I am mainly here to learn.

It often happens that we ignore our own initial learning here and there, especially when certain areas seem surprisingly familiar and easily masterable.

1 Like

I didn’t ask for a philosophical diatribe. I asked you to provide actual technical support, not wild guesses.

1 Like

Hi @baldeuniversel thanks for the response,

I tried this along with dsp, I got this, if I ignore the dsp, Im facing the original issue, no difference.

pygame.error: dsp: No such audio device

also

CVE-2020-27348: A potentially empty LD_LIBRARY_PATH has been set for environment in 'white-canary'. The current working directory will be added to the library path if empty. This can cause unexpected libraries to be loaded.

Also got the above one while snapcraft

1 Like

Hi @popey, thank you for the response

I followed the solution posted by James, I added the alsa-pulseaudio to the parts and layout definition, following the github repo he posted.

this time it seems to find the alsa.conf but something else came up now,

Hello from the pygame community. https://www.pygame.org/contribute.html
ALSA lib control.c:1379:(snd_ctl_open_noupdate) Invalid CTL hw:0
ALSA lib dlmisc.c:283:(snd_dlobj_cache_get0) Cannot open shared library /usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_pcm_pulse.so ((null): libpulsecommon-13.99.so: cannot open shared object file: No such file or directory)
ALSA lib control.c:1379:(snd_ctl_open_noupdate) Invalid CTL hw:0
ALSA lib control.c:1379:(snd_ctl_open_noupdate) Invalid CTL hw:0
ALSA lib dlmisc.c:283:(snd_dlobj_cache_get0) Cannot open shared library /usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_pcm_pulse.so ((null): libpulsecommon-13.99.so: cannot open shared object file: No such file or directory)
ALSA lib control.c:1379:(snd_ctl_open_noupdate) Invalid CTL hw:0
Traceback (most recent call last):
  File "/snap/white-canary/x20/bin/hello", line 5, in <module>
    from src.app import main
  File "/snap/white-canary/x20/lib/python3.8/site-packages/src/app.py", line 12, in <module>
    pygame.mixer.init()
pygame.error: ALSA: Couldn't open audio device: No such device or address

1 Like

Could you please paste the entire snapcraft.yaml or a link to a git repo, so we can debug it?

sure, here is the git repo white-canary

Thanks for taking your time to look in to this.

Thanks. I note you’re not staging libpulse0 as James does. Also James uses the gnome extension which takes away a few headaches :slight_smile:

After adding libpulse0 im still getting the same error. I am sorry if im wrong, but I thought gnome is related to UI, and I dont have any UI related stuff in my app. Regardless of that I added that too, and I got a new error.

RROR: Could not install packages due to an EnvironmentError: [Errno 30] Read-only file system: '__init__.py'

Failed to build 'white-canary'.

Recommended resolution:
Check the build logs and ensure the part's configuration and sources are correct.

without extension and adding libpulse0, Im getting the previous error, I posted.

@ogra @popey @baldeuniversel can you guys help me with this ?

The application cannot find the pulseaudio library, because it’s in a subdirectory that’s not in the LD_LIBRARY_PATH. Use the snippet below (which I have corrected) which will add the path in which the pulseuaudio library resides, to the LD_LIBRARY_PATH.

apps:
    white-canary:
        environment:
            LD_LIBRARY_PATH: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio

The previously posted snippet was incorrect.