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.28k stars 40 forks source link

FileNotFoundError on AppImage with version > 2.8.2 #465

Open smirgol opened 1 month ago

smirgol commented 1 month ago

Describe the bug
Every version of the ProtonUp-QT AppImage that has been released after 2.8.2, when starting the App, I get a pop-up with a FileNotFound error regarding the config.vdf file, followed by an application crash. The path that is mentioned in the error is, obviously, not correct for my installation.

I'm on Ubuntu and have installed steam using the apt package manager (ages ago). The config.vdf file is located in ~/.steam/steam/config/config.vdf The app tries to open the config file from ~/.steam/config/config.vdf, but, while this config folder does exist, it contains no config.vdf, thus the error. Both config folders have files that recently have been modified, so it does not look to me that one of them is a remnant of a very old installation and obsolete.

To Reproduce
Not sure if this can easily be reproduced, but symlinking ~/.steam/root to ~/.steam where the ~/.steam/config holds no config.vdf file, will trigger this.

Expected behavior
I would expect the app to still be able to detect the correct path for the config.vdf file and not to crash if it encounters a config directory without this file.

Desktop (please complete the following information):

Additional context

Looking at the code https://github.com/DavidoTek/ProtonUp-Qt/blame/d7c71a8e0b6f37a9a1832cd89a8d9c8fdccc6cf0/pupgui2/steamutil.py#L221 it kinda blindly assumes that if a config folder exists, that there has to be a config.vdf file inside it and tries to open it without checking for the file to exist in the first place.

In the referenced code above, it now differs from the code that has been used to compile the AppImages 2.91 - 2.10 get_steam_vdf_compat_tool_mapping(vdf.load(open(config_vdf_file))) is now get_steam_vdf_compat_tool_mapping(vdf_safe_load(config_vdf_file))

As far as I understand python, the new approach still won't work, as it will run into the exception when opening the file, as it does not exist. The only upside of the new vdf_safe_load is a new error message (which isn't helping to be honest, as it already printed what did go wrong).

What I think that is happening on my system is that it is checking this path ~/.steam/root which symlinks to ~/.steam/ and there is the config folder, which has no config.vdf - which in turn is in ~/.steam/steam/config

Terminal output

Traceback (most recent call last):
  File "/tmp/.mount_ProtonsCw0BD/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/tmp/.mount_ProtonsCw0BD/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/tmp/.mount_ProtonsCw0BD/usr/local/lib/python3.10/dist-packages/pupgui2/__main__.py", line 2, in <module>
    main()
  File "/tmp/.mount_ProtonsCw0BD/usr/local/lib/python3.10/dist-packages/pupgui2/pupgui2.py", line 588, in main
    MainWindow()
  File "/tmp/.mount_ProtonsCw0BD/usr/local/lib/python3.10/dist-packages/pupgui2/pupgui2.py", line 115, in __init__
    self.update_ui()
  File "/tmp/.mount_ProtonsCw0BD/usr/local/lib/python3.10/dist-packages/pupgui2/pupgui2.py", line 249, in update_ui
    global_ctool_name: str = get_steam_global_ctool_name(install_loc.get('vdf_dir'))
  File "/tmp/.mount_ProtonsCw0BD/usr/local/lib/python3.10/dist-packages/pupgui2/steamutil.py", line 221, in get_steam_global_ctool_name
    d = get_steam_vdf_compat_tool_mapping(vdf.load(open(config_vdf_file)))
FileNotFoundError: [Errno 2] Datei oder Verzeichnis nicht gefunden: '/home/user/.steam/config/config.vdf'
sonic2kk commented 1 month ago

This sounds like another Ubuntu-based distro specificlaly having difficulties with the Steam Client install location...

smirgol commented 1 month ago

It's probably due to my original steam installation being very old and things like paths have changed a couple of times. While steam was working fine, it seemed to have confused your tool.

I went the length to do a fresh installation of steam and now it works. Ideally it would have worked without reinstalling, but I understand that my case - and f.e. #463 - might be edge cases that are not worth putting too much effort into.

DavidoTek commented 1 month ago

In the referenced code above, it now differs from the code that has been used to compile the AppImages 2.91 - 2.10 It's probably due to my original steam installation being very old and things like paths have changed a couple of times.

Yeah, doesn't seem to be related to https://github.com/DavidoTek/ProtonUp-Qt/issues/424

This sounds like another Ubuntu-based distro specificlaly having difficulties with the Steam Client install location... While steam was working fine, it seemed to have confused your tool.

I encountered a similar issue a while ago when I manually created the necessary files for a Steam installation while testing the Snap folders... Might be worth improving the logic a bit so that ProtonUp-Qt at least doesn't crash. I have to take a look at why it detects the installations even though the config.vdf file is missing.

sonic2kk commented 1 month ago

I am not sure why ProtonUp-Qt crashes in the first place. I thought we checked if a potential Steam installation has the VDF files we need before marking it as valid (steamutil#is_valid_steam_installation).

I tried to simulate a leftover Steam installation by creating ~/.steam/debian-installation/config and ProtonUp-Qt doesn't crash. I can create blank config.vdf and libraryfolders.vdf files, and ProtonUp-Qt will then list the installation and trying to select it in that case will cause a crash (because they are not valid VDF files), but it is not a FileNotFound crash.


Also @smirgol I just saw these parts of your reply:

it kinda blindly assumes that if a config folder exists, that there has to be a config.vdf file inside it and tries to open it without checking for the file to exist in the first place.

This function won't get used until a valid Steam installation is found, so this is not really accurate in practice. We check for a valid installation before listing launchers in the dropdown with util#is_valid_launcher_installation, which then for Steam specifically calls steamutil#is_valid_steam_installation, which is where the check for the config directory is (or, more specifically, config/config.vdf and config/libraryfolders.vdf).

We shouldn't be marking a Steam installation as valid unless there is already a config.vdf in it. I even tested and strangely couldn't reproduce a crash, so I'm not sure what step I'm missing. We should not be just going off of a config folder existing in a potential Steam installation directory, in fact, the logic I'm describing was added specifically to fix such an assumption.

Since you've poked around the codebase with fresh eyes, I would be interested to know if you have any insights into why there might be a FileNotFound error. I am stumped as to why ProtonUp-Qt would ever get as far as to look for the config file and crashing when we should have already checked for the existence of this file much earlier. We should never get as far as MainWindow#get_steam_global_ctool_name without a valid Steam installation.

I did all my tests with the Flatpak and when running from source, although I am really not sure what would be so different about the AppImage.

As far as I understand python, the new approach still won't work, as it will run into the exception when opening the file, as it does not exist. The only upside of the new vdf_safe_load is a new error message (which isn't helping to be honest, as it already printed what did go wrong).

This is not the purpose of vdf_safe_load. As noted in #455, the main purpose of this is to create a helper function that loads the VDF files more safely to prevent the UTF-8 errors (seemingly caused by systems with locale issues, i.e. to solve cases like #424).