NetroScript/Graveyard-Keeper-Savefile-Editor

[BUG] Editor unable to locate browser

Opened this issue · 4 comments

It seems the editor is unable to find a browser. I have both Firefox and Chromium installed.

On Pop_OS 20.10 I installed python3-tk and installed all the requirements but when running the editor with python3 main.py it gives you the following error:
Following exception occurred:
Traceback (most recent call last):
File "main.py", line 1020, in
run()
File "main.py", line 1003, in run
eel.start("no settings.html", mode="chrome", port=web_app_options["port"],
File "/home/seren/.local/lib/python3.8/site-packages/eel/init.py", line 158, in start
show(*start_urls)
File "/home/seren/.local/lib/python3.8/site-packages/eel/init.py", line 186, in show
brw.open(start_urls, _start_args)
File "/home/seren/.local/lib/python3.8/site-packages/eel/browsers.py", line 65, in open
raise EnvironmentError("Can't find %s installation" % browser_module.name)
OSError: Can't find Google Chrome/Chromium installation

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "main.py", line 1024, in
run()
File "main.py", line 1003, in run
eel.start("no settings.html", mode="chrome", port=web_app_options["port"],
File "/home/seren/.local/lib/python3.8/site-packages/eel/init.py", line 158, in start
show(*start_urls)
File "/home/seren/.local/lib/python3.8/site-packages/eel/init.py", line 186, in show
brw.open(start_urls, _start_args)
File "/home/seren/.local/lib/python3.8/site-packages/eel/browsers.py", line 65, in open
raise EnvironmentError("Can't find %s installation" % browser_module.name)
OSError: Can't find Google Chrome/Chromium installation

Press Enter to close the application

I bypassed the issue by changing mode values to firefox on lines 997 and 1003 in main.py. Like so:
eel.start("loadsavefile.html", mode="firefox", port=web_app_options["port"],

This is a problem with the used eel module.
Valid options for the mode parameter are actually only chrome, electron, edge, custom - if you input anything else it starts your default browser.

Chrome is hard coded because it has the best support (considering displaying a browser window like an application and for example also the css zoom property).

Eel uses the following code to find the chrome installation

def _find_chrome_linux():
    import whichcraft as wch
    chrome_names = ['chromium-browser',
                    'chromium',
                    'google-chrome',
                    'google-chrome-stable']

    for name in chrome_names:
        chrome = wch.which(name)
        if chrome is not None:
            return chrome
    return None

So assuming eel identifies Pop OS as linux (sys.platform starting with linux) it seems your Chromium installation isn't on the path - or can you start Chromium using chromium-browser in console?

Ah, that does explain it: Chromium is installed as a flatpak so eel can't find it. I prefer to use Firefox anyways, I only installed Chromium to test this out.
Shouldn't the editor fall back on your default browser if no chrome based browser is found? It doesn't explicitly say that in the readme but there's no mention that a Chrome based browser is a hard requirement and there's even mention that testing has been done with other browsers.

I might be wrong, but if I remember correctly, a previous eel version automatically fell back to another browser, if chrome wasn't working, the required eel version of this editor was updated at some point and since then it only tries one browser (the one specified). Maybe an idea for advanced users (which are more or less all users which don't download the "precompiled" Windows version) would be a command line option to select the default browser - which gets passed through eel.