2

I have a python script that is using pygame to load sound and play them. When I run my script without sudo, it is working fine. But when I run the script with sudo, I get these errors:

Home directory not accessible: Permission denied

ALSA lib pcm_mmap.c:341:(snd_pcm_mmap) mmap failed: Invalid argument

Does anyone have any idea on why this is happening? I would like to understand what's going on and not only get a quick fix in case this happens again in another context and because I might need to run the script with sudo.

tripleee
  • 175,061
  • 34
  • 275
  • 318
La Buse
  • 31
  • 1
  • 3
  • 2
    You should never need to run your script with sudo. To answer your question: it seems that sound device permissions are set to not allow root access, only user access. Or, perhaps root's home directory doesn't exist. – mvp Mar 02 '19 at 06:30
  • 1
    `Home directory not accessible: Permission denied` - run the program under `strace`. Does your program changes the user anywhere in it's execution? It would be strange to get `permission denied` for root. Check `whoami` output anywhere in your script. – KamilCuk Mar 02 '19 at 06:45

1 Answers1

1

Apparently, pulseaudio won't work under root.


The OP had edited the question with this; posting it as an answer instead.

tripleee
  • 175,061
  • 34
  • 275
  • 318