DavidoTek / ProtonUp-Qt

Install and manage GE-Proton, Luxtorpeda & more for Steam and Wine-GE & more for Lutris with this graphical user interface.
https://davidotek.github.io/protonup-qt
GNU General Public License v3.0
1.16k stars 39 forks source link

Crash if non-flatpak steam is missing #353

Closed Keelhauled closed 3 months ago

Keelhauled commented 4 months ago

Describe the bug
Crash if non-flatpak steam is missing

To Reproduce
Start program without non-flatpak steam -> crash right away

Desktop (please complete the following information):

Terminal output

Error: Could not get a list of all Steam apps: [Errno 2] No such file or directory: '/home/user/.local/share/Steam/config/libraryfolders.vdf'
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/app/lib/python3.10/site-packages/pupgui2/__main__.py", line 2, in <module>
    main()
  File "/app/lib/python3.10/site-packages/pupgui2/pupgui2.py", line 571, in main
    MainWindow()
  File "/app/lib/python3.10/site-packages/pupgui2/pupgui2.py", line 109, in __init__
    self.update_ui()
  File "/app/lib/python3.10/site-packages/pupgui2/pupgui2.py", line 230, in update_ui
    global_ctool_name: str = get_steam_global_ctool_name(install_loc.get('vdf_dir'))
  File "/app/lib/python3.10/site-packages/pupgui2/steamutil.py", line 206, in get_steam_global_ctool_name
    d = get_steam_vdf_compat_tool_mapping(vdf.load(open(config_vdf_file)))
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/.local/share/Steam/config/config.vdf'
Keelhauled commented 4 months ago

Looks like it's happening because I still have files in the .local/share/Steam/compatibilitytools.d/. Probably a rare condition but could be worth checking for.

sonic2kk commented 4 months ago

Having Steam files from a previous installation but no valid Steam install for that type is probably causing the crash as you point out, rather than anything to do with the Flatpak.

Although, I thought we'd be checking for a valid Steam install earlier:

https://github.com/DavidoTek/ProtonUp-Qt/blob/89bdbcf9843210c6e479a2834bde80ed7637c7b4/pupgui2/constants.py#L26-L36

Oh, wait, we default to POSSIBLE_STEAM_ROOTS[0], which is the path you gave, ~/.local/share/Steam.

I guess there isn't a check for Steam being missing. We check for other launchers being missing, but I guess ProtonUp-Qt always expects Steam.

sonic2kk commented 4 months ago

This could be the culprit:

https://github.com/DavidoTek/ProtonUp-Qt/blob/89bdbcf9843210c6e479a2834bde80ed7637c7b4/pupgui2/util.py#L207

Since ~/.local/share/Steam does exist. The above code in constants.py only exists to pick the right Steam install location and assumes Steam (non-flatpak) is installed, but needs to find it from a set of possible paths. However in your case, even though the check in constants.py fails, ~/.local/share/Steam does exist.

Perhaps we need a different helper function to call in util.py on the line linked to check for a valid installation depending on the launcher.

That line is part of a bigger loop that loops through all POSSIBLE_INSTALL_LOCATIONS:

https://github.com/DavidoTek/ProtonUp-Qt/blob/89bdbcf9843210c6e479a2834bde80ed7637c7b4/pupgui2/constants.py#L38

Each install location is a dictionary with a display_name key, which distinguishes between different types, such as Steam, Steam Flatpak, and Steam Snap. We could pass this dictionary to a helper function instead of using os.path.exists, and the helper function will perform checks depending on the launcher type. We could further break this down, grabbing the path off this dictionary and then checking if certain files we need exist at a given path (such as grabbing the Steam install path and checking if a config.vdf exists). We don't actually care if Steam is installed per se, just if the files we need per-launcher exist (and usually, the files we need are removed if a given program is uninstalled, such as config.vdf).

sonic2kk commented 4 months ago

I'll take a stab at getting a draft of something ready for this later tonight if no one else is looking at it. No guarantee I'll get the approach right but if I don't end up opening any PR I'll at least note the pitfalls I ran into :-)

Bug23451 commented 4 months ago

Ran into the same issue here, if it helps I copied the missing file from another PC and it worked. The UI displays the native steam location as an option despite there not being a native installation.

sonic2kk commented 4 months ago

Deleting the empty directories (i.e. removing all of ~/.local/share/Steam if it is entirely unused, or wherever your Steam path was) would've also solved the problem, instead of copying the files over. This would also resolve the UI displaying the install location.

The issue is that right now ProtonUp-Qt only looks to see if the Steam directories exist. If they do, it assumes Steam is installed, and when it tries to look for the VDF files it needs, they don't exist and it crashes. #356 is aiming to solve this by introducing a stricter check for these data files, with some other changes included (mainly refactoring some semi-related logic out of constants.py).


I am a bit curious though as to how a system can end up with these left behind directories. Did you uninstall regular Steam and replace it with Flatpak Steam, and this is just left-behind installation files? Nothing changed in the logic, so if this is the case, it seems there are more user switching to Flatpak Steam, that is, unistalling a previous Steam installation and switching. In other words, a use-case that has suddenly cropped up, which is why I ask. Just curiosity is all :grinning:

Bug23451 commented 3 months ago

Arch linux was having a day the native package wasn't rendering so I uninstalled native and downloaded the flatpak version for troubleshooting.

sonic2kk commented 3 months ago

Interesting, as an Arch user for many years I have never encountered that issue, but makes sense.