Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

Error and GUI terminates back to ES when launching RetroPie-Setup direct on machine (libudev?) - but SSH is ok



  • Hi,

    I have a bit of a weird one. I have RetroPie installed on Ubuntu Server 18.04 and it's been working great for ages. However a short while ago I noticed this error crop up when launching RetroPie-Setup directly on the machine itself:

    IMG_20190205_220559.jpg

    It would then terminate and return to ES.

    However, when managing the box via SSH I do not get this issue. Originally, I updated RetroPie-Setup and this seemed to fix the problem, as far I was aware. And then it was was fine.

    Anyway, tonight, after running some routine OS updates, and updating my RetroPie-Setup again, this error has returned, but I cannot seem to shift it this time. Again, via SSH I get no errors.

    Does anyone know what might be occurring here? I am not sure where on the OS to grab the full error from, perhaps someone can point me to the right place so I can give more information. Perhaps this an OS component which is getting upgraded and causing a problem? I haven't butchered my RetroPie-Setup or anything silly, everything is pretty stock on the setup-script front.

    Thanks in advance.



  • Weirdly, this error isn't happening 100% of the time, and when I do get into the RetroPie-Setup GUI on the machine directly, the mappings for the controller are all messed up in the menus (right shoulder acts as A). However in ES and games, it's all fine. This isn't something i've seen before so is new. If I plug a keyboard in I can use the menu as normal.

    It's really confusing as it has been working great for months, through basic updates to the OS to all RetroPie related updates.

    The error I took a screenshot of above could well be a red herring, as it doesn't always appear. Sometimes RetroPie-Setup loads, and then crashes out again back to ES with no obvious error. Same goes for running things like configuration editor, etc. Runcommand always works though.



  • Bit more testing - just to add to the strange unpredictability of this one:

    • Start OS from fresh boot
    • Once loaded, quit ES straight away, and directly on the machine open up a terminal
    • sudo ./retropie_setup.sh and the GUI loads, but crashes straight away with the above error at the bottom of the screen
    • run exactly the same command again (up arrow + return), and then it works 2nd time.
    • after this, it appears to continue to work if I relaunch ES. If I reboot the system, the cycle repeats itself.

    **edit - note this seemed at first to be absolutely consistent behaviour, but now it just crashes every time, except for when I use SSH, it is all good.

    The full error again:

    Exception AttributeError: "'Context' object has no attribute '_libudev'" in <bound method Context.__del__ of <pyudev.core.Context object at 0x7fb309ef6d50>> ignored
    

    Very confused, this is new behaviour so unless some changes have been made in RetroPie-Setup (looking at the commits i'm not sure anything would cause this?) or an OS update has caused some strangeness.

    A bit of googling suggests the error is related to Python possibly.

    @BuZz sorry to ask directly about this, but I thought I remembered you use Ubuntu for RetroPie dev/testing - any idea or pointers you can offer before I start backing up and going nuclear?

    Getting this 'appliance' up and running has been a really great learning experience, and i've worked so hard on many different elements to get it looking great, but i'm absolutely stumped with this random error which has started occurring.

    Many Thanks



  • Very similar behaviour observed here on another recent thread I just discovered:
    https://retropie.org.uk/forum/topic/21052/retropie_setup-sh-crashing-via-es-and-controls-strange


  • Global Moderator

    I have a few suggestions - stabs in the dark for the time being, but perhaps something may help.

    1. Manually re-install python-pyudev. It should be installed by the script, but let's force a re-install just in case the files became corrupt:

    sudo apt-get install --reinstall python-pyudev

    1. Remove the joy2key.pyc file, just in case the compiled python script has some kind of error:

    sudo rm /opt/retropie/supplementary/runcommand/joy2key.pyc

    1. Reinstall the runcommand scriptmodule (via the GUI, or...):

    sudo ./retropie_packages runcommand



  • @psyke83

    Hey there - thanks for the reply, I actually already just tried points 1 and 3 about ten minutes ago to no avail, but let me try point 2 and will come back to you.

    Seems odd there is another thread which I linked above experiencing the same issue.

    Will let you know in a sec.


  • Global Moderator

    @movisman said in Error and GUI terminates back to ES when launching RetroPie-Setup direct on machine (libudev?) - but SSH is ok:

    @psyke83

    Hey there - thanks for the reply, I actually already just tried points 1 and 3 about ten minutes ago to no avail, but let me try point 2 and will come back to you.

    Seems odd there is another thread which I linked above experiencing the same issue.

    Will let you know in a sec.

    Cool. If you are able to reproduce the issue by hurriedly performing the steps, then perhaps systemd has not finished initializing all of the udev-related services properly. The error you're seeing is definitely coming from the joy2key.py script -- but there haven't been any changes to the file in about a year, so it's likely an issue unique to your installation.



  • @psyke83

    So, I tried all of the above but unfortunately no change.

    One thing I do want to mention, is that beforehand when I was having mixed success (when the error I pasted above sometimes appeared) - since reinstalling python-pyudev it hasn't worked once since, and i've not seen that error again either. This could be a red herring though. When I retry, RetroPie-Setup just shows it's GUI for a second, then crashes out. Same for config editor, show ip - however runcommand, bluetooth, es-themes will launch without crashing.

    It was all working ok but I did install some general OS updates this evening and update the setup script.

    The other thread I linked does describe a very similar thing and that user is also 18.04.1 and sounds like a similar setup.

    Any other ideas?

    Thanks a lot!


  • Global Moderator

    Do you see error message if you manually launch joy2key?

    Thsis should be enough:
    /opt/retropie/supplementary/runcommand/joy2key.py /dev/input/js0 kcub1 kcuf1 kcuu1 kcud1 0x0a 0x09

    (This should be able to launch with or without a controller connected, but you shouldn't expect to see any output either way).

    Perhaps a recent update (perhaps a backport, if you've enabled that channel) has caused a python compatibility issue?



  • @psyke83

    Without a controller connected, I don't get any error messages straight away, the cursor just sits there, which I guess is expected.

    If I switch on my Xbox One controller (no keyboard plugged in) and run again, I don't get any error messages, same happens, however when I push certain buttons (not A/B/X/Y) but others like the d-pad or shoulders I get something like this:

    pi@retropie-pc:~/RetroPie-Setup$ ./scriptmodules/supplementary/runcommand/joy2key.py /dev/input/js0
    Traceback (most recent call last):
      File "./scriptmodules/supplementary/runcommand/joy2key.py", line 269, in <module>
        if process_event(event):
      File "./scriptmodules/supplementary/runcommand/joy2key.py", line 207, in process_event
        hex_chars = axis_codes[3]
    IndexError: list index out of range
    

    The line can differ depending on button pressed.

    FYI, I don't believe I have any backports enabled, the python-pyudev version I have installed is:

    pi@retropie-pc:~/RetroPie-Setup$ apt list python-pyudev 
    Listing... Done
    python-pyudev/bionic,now 0.21.0-1 all [installed]
    

    Running /etc/apt/sources.list I get only these:

    deb http://archive.ubuntu.com/ubuntu bionic main universe
    deb http://archive.ubuntu.com/ubuntu bionic-security main universe
    deb http://archive.ubuntu.com/ubuntu bionic-updates main universe
    

    No backports there? I do have a feeling perhaps some sort of update has caused a compatibility issue maybe, but I am not sure.

    Thanks a lot!



  • @psyke83

    Now, randomly, it is back at the state where it will produce the error I mentioned earlier at the base of the retropie_setup.sh GUI, which is constant, however if I drop out of ES to a terminal and run retropie_setup.sh that way, on first launch it fails, but subsequent attempts it then works. One you finally get in, controls are still totally messed up like the other thread mentions, when using the controller to navigate.

    Such a weird problem this. Really have to hit the sack in the next 30 minutes as it's so late in the UK now, but will continue any recommendations you have as soon as I pick them up.

    Cheers for all the help so far.


  • Global Moderator

    I have an Ubuntu VM for testing and I see the same behavior - the setup starts, but quickly exits, without doing anything. I'm not sure if it's the same problem, since I don't see the message you reported.
    Btw, running joy2key without any arguments like you did - it's probably ok if you're getting that error.

    What's funny is that if I start the setup script from a simple xterm (and not Gnome Terminal), then the setup script functions normally. Can you try doing the same to see if maybe the terminal is to blame ?

    EDIT: it seems that even if setup works fine from an empty xterm, but if I start ES from the xterm and then access the setup it still doing the same thing - so scratch the test. But for now I know it's not from gnome-terminal.



  • @mitu

    Hey,

    Thanks for the reply. Bit of a classic, stayed up so late trying to resolve the issue I was a bit late for work - whoops!

    That was a really interesting theory with the terminal - I didn't think of trying that. I saw your message this morning and planned to test but then saw your edit, so I haven't done anything with it yet as it doesn't sound terminal related.

    I am glad you were able to replicate it though, at least it means it is not likely to be something with my setup, also that other thread sounds like a similar thing - I am pretty meticulous about keeping my Ubuntu instance clean for RetroPie - the little machine it runs off doesn't actually do anything else but run Ubuntu Server with RetroPie on top, plus all the emus of course. So it has minimal apps on it as a whole really, and anything I do install which is temporary, I do try to remove as I go.

    Thanks


  • Global Moderator

    @movisman Yeah, the thing is I don't get the error with

    Exception AttributeError: "'Context' object has no attribute '_libudev'" in <bound method Context.__del__ of <pyudev.core.Context object at 0x7fb309ef6d50>> ignored
    

    but I also don't have a controller installed (it might appear only when a controller is connected ?). I also never started the setup script from ES until now, since it's a test VM for me, so I'm not sure if it's an error that was there from the beginning or just started to happen.

    I'll keep poking at it - eventually I can test in a real Ubuntu install in the week-end.



  • @mitu

    One thing to note, is I don't always get that error either.

    It is either one or the other, but it doesn't jump between producing an error or not. What I mean, is last night I tried it 20x times and didn't get a single error, it would just load then crash like what you are seeing. Yet on another boot or combination the error would then appear consistently.

    You might be right about the controller thing, the Xbox One controller powers off itself after 15 minutes or so and that could be a factor.

    Regarding when I first saw the error, I think it was a few weeks back I noticed it, but once I had updated the setup script, it seemed to go away, or so I thought. I've not seen it since (but to be fair I haven't really been into setup via ES) until last night, when I noticed issues straight after doing an apt get upgrade to grab a handful of OS updates, and updating my setup-script so I could update Retroarch to 1.7.6. I then noticed while I was working on changes to the Chiceulo theme. The fact the controls are totally messed up (when it does load) is new thing too, just like is mentioned in the other thread.

    Just to clarify though, I have had the Ubuntu Server 18.04.1 instance running since November and this was not an issue up until recently.

    If you need me to extract or test anything at all, just let me know. Keen to get it resolved but it's a real strange issue, let me know if you find anything.

    I tagged Jools earlier in the thread as I think he has an Ubuntu instance also, however i'm not sure if it's 16.04/18.04/18.10 or even if he actually still has one. I know he is forever getting bombarded with issues so I won't chase him up. However if you guys have any dialog between yourselves maybe it's worth mentioning to see if he can replicate it also.

    Thanks for all the help so far!


  • Global Moderator

    I can't reproduce the issue, but I do have a few suggestions to help troubleshoot.

    I added some debugging to my script, and ran it manually with these arguments:
    /opt/retropie/supplementary/runcommand/joy2key.py /dev/input/js0 0x00 0x00 kich1 kdch1 0x20 0x71

    It's clear that the get_button_codes function (which is the only function that utilizes the pyudev's Context()) will not be called if there's no device present (in this case, /dev/input/js0).

    So, try the above command while your controller is connected (making sure to substitute the device name for your actual controller, if it's different).

    If the script works correctly, nothing will display, but pressing buttons on your controller will trigger control codes to print on the terminal.


  • Global Moderator

    @psyke83 How does the script work without a joystick present ? In my tests I only have a keyboard (mapped as a gamepad in ES) and it's randomly failing or working - similar to how @movisman experienced - and it doesn't matter if it's started from ES or not.

    The failure is 'consistent' - if it fails once, then it will fail again until either I restart ES or the terminal I'm using to start it.


  • administrators

    It's strange as even if the joy2key fails, it shouldn't cause retropie_setup to exit.


  • administrators

    Might be worth checking if there is anything additional logged in logs/ after it quits.


  • Global Moderator

    It manifests as you press Cancel on the dialog page. @psyke83 can you share your modifications to the script that prints the event codes ? I can repeat the tests tomorrow (I don't have right now access to the Ubuntu machine I was testing today) and see if something is logged.
    My next line of test would be also to change the DE to something simpler.

    @buzz In my tests, there's nothing logged, although I see the setup menu screen briefly before closing in.



Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.