Ruby permission for PulseAudio

I get a permission error when trying to use “paplay” in the ruby script…
How can I connect Ruby snap with PulseAudio (I have tried snap connect ruby:pulseaudio :pulseaudio)?

do you ship the paplay binary ? the interface plug only grants access to the socket of the running pulse daemon but doesnt give you access to the tools.

Simply put… I have a script written in ruby with this content:

spawn(‘paplay foo’)

When I run it, it trows this error message:

Connection failure: Connection refused
pa_context_connect() failed: Connection refused

No one is giving me an answer to that question. Can I somehow add interface pulseaudio to ruby, is there anything I can do?

yes, your snapcraft.yaml should use the audio-playback plug (to grant access to the pulseaudio socket) for your app and you need to ship the paplay binary inside your snap and execute it from there… like i said above …

Ok, thank you ogra. Unfortunately, I don’t know how to do that. I’m not trying to create a snap app if you did get that impression. It is a small ruby program/script which I want to be able to use audio-playback while using snap ruby as an interpreter. Should I just add snapcraft.yaml in program folder?

OOPS … hanging around here in that forum somehow leaves you mindcuffed :stuck_out_tongue: indeed i assumed you want to build a snap :slight_smile:

Haha, I’m glad you are trying to help. So is there any way for me to give ruby snap permission to audio-playback plug?

You said you’re using a call to paplay to play back your audio. It looks like your code is correctly starting the paplay program and it is actually paplay that is giving the error… I think this might be an issue with the environment set up when calling ruby from the snap to run your application. The Ruby snap is set to classic confinement so it should not be hitting any apparmor restrictions but we might be wise to verify that by checking the syslog for any DENIED messages as you run your app.

Feb 19 16:17:21 kernel: [156229.941546] pcieport 0000:00:1c.0: AER: Corrected error received: 0000:00:1c.0
Feb 19 16:17:21 kernel: [156229.941551] pcieport 0000:00:1c.0: AER: PCIe Bus Error: severity=Corrected, type=Data Link Layer, (Transmitter ID)
Feb 19 16:17:21 kernel: [156229.941553] pcieport 0000:00:1c.0: AER: device [8086:a112] error status/mask=00001000/00002000
Feb 19 16:17:21 kernel: [156229.941555] pcieport 0000:00:1c.0: AER: [12] Timeout

Is this helpful?