foolishmortalbuilders / magicbandreader

Reads magic bands and plays sounds and lights up leds, just like the real thing.
Other
46 stars 24 forks source link

error: XDG_RUNTIME_DIR not set in the environment #11

Open SonicGerkor opened 4 years ago

SonicGerkor commented 4 years ago

Error while starting magicband.py

I get this error after it tries to load magicband.py on startup:

error: XDG_RUNTIME_DIR not set in the environment

Any thoughts?

SonicGerkor commented 3 years ago

I have googled and tried everything, uninstall and reinstall a bunch of times, still stuck with this. Now the error shows as: (/run/user/1000) is not owned by us (uid 0). but by uid 1000

I keep trying to see how to change this but so far unable to do so.

Pls help!

nukraze commented 3 years ago

I'm also running into this same issue on a RaspberryPi Zero. Has there been any update on addressing this?

SonicGerkor commented 3 years ago

Nah men, I’m still struggling with this, the script runs and the leds turn on, but because of that runtimeerror thing it exits the script and i cant read ant bands :(

SonicGerkor commented 3 years ago

I'm using a RPI2 and keep having this issue...maybe it's something to do with the Rpi? I don't have a 3B+ to try it

locvez commented 3 years ago

I had this same issue running Pi OS Lite - I installed the full O/S instead and this fixed the problem.

I haven't been able to test the rest of it yet as I think my RFID reader is faulty - nothing happens when a band is scanned so waiting for new readers.

SonicGerkor commented 3 years ago

@locvez did you install the same things via terminal? Or did you change something in between, I opened it up and it was a graphical interface, I located the terminal but found it a bit confusing on where to install or where to begin following the install options

irvingwa commented 2 years ago

Hey I know this is an old issue but if anyone else runs into this its because of the pygame library used. I switched it to just use the play command via the os. https://vitux.com/play-mp3-files-on-the-ubuntu-command-line/

And then you can just replace the playsound function with something like # play sound def playSound(self, fname): os.system("play -v 10.0 " + fname)

joncherston commented 2 years ago

Ok, I'm by no means an expert on this, but have been wrestling with this issue for a while. Best I can tell, alsalib doesn't like using user 1000 which is what we do using sudo. So, the runtime directory has to be set manually to user 0 which alsalib wants to use for audio. I tried irvingwa's solution to play the command via the os gave me new errors, although I likely did something wrong. I finally got rid of the XDG_RUNTIME_DIR error by adding the following line to the magicband.py file, just above the os.environ line:

os.environ['XDG_RUNTIME_DIR'] = "/run/user/0"

Hope that helps someone else. I'm also hoping this will resolve my buffer underrun error, where there appears to be a memory leak, but time will tell.

joncherston commented 2 years ago

Ok, quick update. That line does resolve the XDG_RUNTIME_DIR error. However, it does not resolve the buffer underrun issue.