Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

UnboundedLocalError #46

Open
anark10n opened this issue Dec 30, 2018 · 1 comment
Open

UnboundedLocalError #46

anark10n opened this issue Dec 30, 2018 · 1 comment

Comments

@anark10n
Copy link

Hey there,
Running protontricks on a game, or even the gui, produces the following error:

Traceback (most recent call last):
File "/usr/bin/protontricks", line 309, in
steam_lib_dirs = get_steam_lib_dirs(steam_dir)
File "/usr/bin/protontricks", line 222, in get_steam_lib_dirs
with open(folders_vdf_path, "r") as f:
UnboundLocalError: local variable 'folders_vdf_path' referenced before assignment`

Any ideas on how to resolve this?

@jonasof
Copy link

jonasof commented Feb 16, 2020

Looking at the code it seems an "else" block is missing, so the error is triggered later inside the try block:

    # Try finding Steam library folders using libraryfolders.vdf in Steam root
    if os.path.isdir(os.path.join(steam_dir, "steamapps")):
        folders_vdf_path = os.path.join(
            steam_dir, "steamapps", "libraryfolders.vdf")
    elif os.path.isdir(os.path.join(steam_dir, "SteamApps")):
         folders_vdf_path = os.path.join(
            steam_dir, "SteamApps", "libraryfolders.vdf")
    try:
        with open(folders_vdf_path, "r") as f:
            library_folders = parse_library_folders(f.read())
    except OSError:
        # libraryfolders.vdf doesn't exist; maybe no Steam library folders
        # are set?
        library_folders = []

I got the error because my steamapps folder was not inside steam folder - I configured in "Settings -> Downloads -> Library Folders" to point to other disk:

image

My lazy solution was to unify back steamapps to steam folder and the script executed well. Maybe creating symlinks would work too but I haven't tested it. Would be nice if protontricks support non default folders or at least trigger a proper error if the default folders are not found.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants