kra-mo / cartridges

A GTK4 + Libadwaita game launcher
GNU General Public License v3.0
628 stars 32 forks source link

Won't open Steam game (error) #258

Closed pchmykh closed 5 months ago

pchmykh commented 5 months ago

Describe the bug An error occurs when I'm trying to start Steam game: "Check your DISPLAY environment variable and make sure that you have enabled X. If you are running remotely, make sure that you have a remote connection which will allow an X connection. For more information visit https://support.steampowered.com/kb_article.php?ref=4050-WOJB-0608"

To Reproduce Steps to reproduce the behavior:

  1. Open Cartridges
  2. Click on some Game
  3. Error comes up

Expected behavior

  1. Open Cartridges
  2. Click on some Game
  3. Game starts

Screenshots Screenshot from 2024-05-04 11-52-31

Logs

49:23 - DEBUG: Starting page.kramo.Cartridges v2.8.3 (release)
49:23 - DEBUG: Python version: 3.11.9 (main, Nov 10 2011, 15:00:00) [GCC 13.2.0]
49:23 - DEBUG: Flatpak version: Flatpak 1.15.8
49:23 - DEBUG: Platform: Linux-6.8.7-300.fc40.x86_64-x86_64-with-glibc2.38
49:23 - DEBUG:  System: Linux
49:23 - DEBUG:  Node: fedora
49:23 - DEBUG:  Release: 6.8.7-300.fc40.x86_64
49:23 - DEBUG:  Version: #1 SMP PREEMPT_DYNAMIC Wed Apr 17 19:21:08 UTC 2024
49:23 - DEBUG:  Machine: x86_64
49:23 - DEBUG:  Processor: 
49:23 - DEBUG: ─────────────────────────────────────
49:25 - DEBUG: Importing games from source itch
49:25 - DEBUG: Importing games from source lutris
49:25 - DEBUG: Importing games from source flatpak
49:25 - DEBUG: Importing games from source bottles
49:25 - DEBUG: Importing games from source steam
49:25 - DEBUG: Importing games from source heroic
49:25 - INFO: Source itch skipped, bad location
49:25 - DEBUG: Importing games from source retroarch
49:25 - INFO: Source lutris skipped, bad location
49:25 - DEBUG: Importing games from source legendary
49:25 - DEBUG: Importing games from source desktop
49:25 - INFO: Source heroic skipped, bad location
49:25 - INFO: Source retroarch skipped, bad location
49:25 - INFO: Scanning source desktop
49:25 - INFO: Source legendary skipped, bad location
49:25 - DEBUG: Import done for source itch
49:25 - DEBUG: Import done for source lutris
49:25 - DEBUG: Import done for source heroic
49:25 - DEBUG: Import done for source retroarch
49:25 - DEBUG: Import done for source legendary
49:25 - DEBUG: Resolved value for schema key flatpak-system-location: /var/lib/flatpak
49:25 - DEBUG: Resolved value for schema key steam-location: /home/pchmykh/.var/app/com.valvesoftware.Steam/data/Steam
49:25 - DEBUG: Resolved value for schema key bottles-location: /home/pchmykh/.var/app/com.usebottles.bottles/data/bottles
49:25 - INFO: Scanning source steam
49:25 - INFO: Scanning source bottles
49:25 - DEBUG: New store game Steamworks Common Redistributables (steam_228980)
49:25 - INFO: Imported Steamworks Common Redistributables (steam_228980)
49:25 - DEBUG: New store game Steam Linux Runtime 2.0 (soldier) (steam_1391110)
49:25 - INFO: Imported Steam Linux Runtime 2.0 (soldier) (steam_1391110)
49:25 - DEBUG: New store game Dota 2 (steam_570)
49:25 - INFO: Imported Dota 2 (steam_570)
49:25 - DEBUG: New store game Proton Experimental (steam_1493710)
49:25 - INFO: Imported Proton Experimental (steam_1493710)
49:25 - DEBUG: New store game Steam Linux Runtime 1.0 (scout) (steam_1070560)
49:25 - INFO: Imported Steam Linux Runtime 1.0 (scout) (steam_1070560)
49:25 - DEBUG: Resolved value for schema key flatpak-user-location: /home/pchmykh/.local/share/flatpak
49:25 - INFO: Scanning source flatpak
49:25 - DEBUG: New store game Quake Live (steam_282440)
49:25 - INFO: Imported Quake Live (steam_282440)
49:25 - DEBUG: New store game Proton 8.0 (steam_2348590)
49:25 - INFO: Imported Proton 8.0 (steam_2348590)
49:25 - DEBUG: New store game Proton EasyAntiCheat Runtime (steam_1826330)
49:25 - INFO: Imported Proton EasyAntiCheat Runtime (steam_1826330)
49:25 - DEBUG: New store game Steam Linux Runtime 3.0 (sniper) (steam_1628350)
49:25 - INFO: Imported Steam Linux Runtime 3.0 (sniper) (steam_1628350)
49:25 - DEBUG: Starting new HTTPS connection (1): store.steampowered.com:443
49:25 - DEBUG: Starting new HTTPS connection (1): store.steampowered.com:443
49:25 - DEBUG: Starting new HTTPS connection (1): store.steampowered.com:443
49:25 - DEBUG: New store game Warsow (flatpak_net.warsow.Warsow)
49:25 - DEBUG: Starting new HTTPS connection (1): store.steampowered.com:443
49:25 - DEBUG: Starting new HTTPS connection (1): store.steampowered.com:443
49:25 - DEBUG: Starting new HTTPS connection (1): store.steampowered.com:443
49:25 - DEBUG: Starting new HTTPS connection (1): store.steampowered.com:443
49:25 - DEBUG: Starting new HTTPS connection (1): store.steampowered.com:443
49:25 - DEBUG: Starting new HTTPS connection (1): store.steampowered.com:443
49:25 - INFO: Imported Warsow (flatpak_net.warsow.Warsow)
49:25 - DEBUG: Import done for source desktop
49:25 - DEBUG: Import done for source bottles
49:25 - DEBUG: Import done for source steam
49:25 - DEBUG: Import done for source flatpak
49:25 - DEBUG: SteamAPIManager done for flatpak_net.warsow.Warsow
49:25 - DEBUG: CoverManager done for flatpak_net.warsow.Warsow
49:25 - DEBUG: FileManager done for flatpak_net.warsow.Warsow
49:25 - DEBUG: SgdbManager done for flatpak_net.warsow.Warsow
49:25 - DEBUG: DisplayManager done for flatpak_net.warsow.Warsow
49:25 - DEBUG: https://store.steampowered.com:443 "GET /api/appdetails?appids=2348590 HTTP/1.1" 200 49
49:25 - DEBUG: Appid 2348590 not found
49:25 - DEBUG: SteamAPIManager done for steam_2348590
49:25 - DEBUG: CoverManager done for steam_2348590
49:25 - DEBUG: FileManager done for steam_2348590
49:25 - DEBUG: SgdbManager done for steam_2348590
49:25 - DEBUG: DisplayManager done for steam_2348590
49:25 - DEBUG: https://store.steampowered.com:443 "GET /api/appdetails?appids=1493710 HTTP/1.1" 200 49
49:25 - DEBUG: Appid 1493710 not found
49:25 - DEBUG: SteamAPIManager done for steam_1493710
49:25 - DEBUG: CoverManager done for steam_1493710
49:25 - DEBUG: SgdbManager done for steam_1493710
49:25 - DEBUG: DisplayManager done for steam_1493710
49:25 - DEBUG: FileManager done for steam_1493710
49:25 - INFO: Import done
49:25 - DEBUG: https://store.steampowered.com:443 "GET /api/appdetails?appids=1391110 HTTP/1.1" 200 49
49:25 - DEBUG: Appid 1391110 not found
49:25 - DEBUG: SteamAPIManager done for steam_1391110
49:25 - DEBUG: CoverManager done for steam_1391110
49:25 - DEBUG: SgdbManager done for steam_1391110
49:25 - DEBUG: DisplayManager done for steam_1391110
49:25 - DEBUG: FileManager done for steam_1391110
49:25 - DEBUG: https://store.steampowered.com:443 "GET /api/appdetails?appids=1826330 HTTP/1.1" 200 49
49:25 - DEBUG: Appid 1826330 not found
49:25 - DEBUG: https://store.steampowered.com:443 "GET /api/appdetails?appids=570 HTTP/1.1" 200 3649
49:25 - DEBUG: https://store.steampowered.com:443 "GET /api/appdetails?appids=1628350 HTTP/1.1" 200 49
49:25 - DEBUG: https://store.steampowered.com:443 "GET /api/appdetails?appids=282440 HTTP/1.1" 200 48
49:25 - DEBUG: Appid 1628350 not found
49:25 - DEBUG: Appid 282440 not found
49:25 - DEBUG: https://store.steampowered.com:443 "GET /api/appdetails?appids=228980 HTTP/1.1" 200 48
49:25 - DEBUG: Appid 228980 not found
49:25 - DEBUG: https://store.steampowered.com:443 "GET /api/appdetails?appids=1070560 HTTP/1.1" 200 49
49:25 - DEBUG: Appid 1070560 not found
49:25 - DEBUG: SteamAPIManager done for steam_1826330
49:25 - DEBUG: CoverManager done for steam_1826330
49:25 - DEBUG: SteamAPIManager done for steam_570
49:25 - DEBUG: CoverManager done for steam_570
49:25 - DEBUG: SteamAPIManager done for steam_1628350
49:25 - DEBUG: CoverManager done for steam_1628350
49:25 - DEBUG: SteamAPIManager done for steam_282440
49:25 - DEBUG: CoverManager done for steam_282440
49:25 - DEBUG: SteamAPIManager done for steam_228980
49:25 - DEBUG: CoverManager done for steam_228980
49:25 - DEBUG: SteamAPIManager done for steam_1070560
49:25 - DEBUG: CoverManager done for steam_1070560
49:25 - DEBUG: SgdbManager done for steam_1826330
49:25 - DEBUG: DisplayManager done for steam_1826330
49:25 - DEBUG: FileManager done for steam_1826330
49:25 - DEBUG: FileManager done for steam_570
49:25 - DEBUG: SgdbManager done for steam_570
49:25 - DEBUG: DisplayManager done for steam_570
49:25 - DEBUG: FileManager done for steam_1628350
49:25 - DEBUG: SgdbManager done for steam_1628350
49:25 - DEBUG: DisplayManager done for steam_1628350
49:25 - DEBUG: FileManager done for steam_282440
49:25 - DEBUG: SgdbManager done for steam_282440
49:25 - DEBUG: DisplayManager done for steam_282440
49:25 - DEBUG: SgdbManager done for steam_228980
49:25 - DEBUG: DisplayManager done for steam_228980
49:25 - DEBUG: FileManager done for steam_228980
49:25 - DEBUG: SgdbManager done for steam_1070560
49:25 - DEBUG: DisplayManager done for steam_1070560
49:25 - DEBUG: FileManager done for steam_1070560
49:36 - INFO: Launching `flatpak-spawn --host /bin/sh -c 'xdg-open steam://rungameid/570'`

System (please complete the following information):

kra-mo commented 5 months ago

Does xdg-open steam://rungameid/570 work when ran inside your terminal?

pchmykh commented 5 months ago

Behavior of the app now has been changed. I have no longer any errors, just "Dota 2 launched" notification, but nothing happens. xdg-open steam://rungameid/570 is working, Steam is starting and launching Dota 2 game.

kra-mo commented 5 months ago

Are you running GNOME Wayland?

pchmykh commented 5 months ago

I believe yes, ~$ echo $XDG_SESSION_TYPE returns wayland. Debugging information now looking like this:

53:18 - DEBUG: Starting page.kramo.Cartridges v2.8.3 (release)
53:18 - DEBUG: Python version: 3.11.9 (main, Nov 10 2011, 15:00:00) [GCC 13.2.0]
53:18 - DEBUG: Flatpak version: Flatpak 1.15.8
53:18 - DEBUG: Platform: Linux-6.8.8-300.fc40.x86_64-x86_64-with-glibc2.38
53:18 - DEBUG:  System: Linux
53:18 - DEBUG:  Node: fedora
53:18 - DEBUG:  Release: 6.8.8-300.fc40.x86_64
53:18 - DEBUG:  Version: #1 SMP PREEMPT_DYNAMIC Sat Apr 27 17:53:31 UTC 2024
53:18 - DEBUG:  Machine: x86_64
53:18 - DEBUG:  Processor: 
53:18 - DEBUG: ─────────────────────────────────────
53:18 - DEBUG: New store game Warsow (flatpak_net.warsow.Warsow)
53:18 - DEBUG: DisplayManager done for flatpak_net.warsow.Warsow
53:18 - DEBUG: New store game Proton 8.0 (steam_2348590)
53:18 - DEBUG: DisplayManager done for steam_2348590
53:18 - DEBUG: New store game Proton Experimental (steam_1493710)
53:18 - DEBUG: DisplayManager done for steam_1493710
53:18 - DEBUG: New store game Steam Linux Runtime 2.0 (soldier) (steam_1391110)
53:18 - DEBUG: DisplayManager done for steam_1391110
53:18 - DEBUG: New store game Proton EasyAntiCheat Runtime (steam_1826330)
53:18 - DEBUG: DisplayManager done for steam_1826330
53:18 - DEBUG: New store game Dota 2 (steam_570)
53:18 - DEBUG: DisplayManager done for steam_570
53:18 - DEBUG: New store game Steam Linux Runtime 3.0 (sniper) (steam_1628350)
53:18 - DEBUG: DisplayManager done for steam_1628350
53:18 - DEBUG: New store game Quake Live (steam_282440)
53:18 - DEBUG: DisplayManager done for steam_282440
53:18 - DEBUG: New store game Steamworks Common Redistributables (steam_228980)
53:18 - DEBUG: DisplayManager done for steam_228980
53:18 - DEBUG: New store game Steam Linux Runtime 1.0 (scout) (steam_1070560)
53:18 - DEBUG: DisplayManager done for steam_1070560
53:20 - INFO: Launching `flatpak-spawn --host /bin/sh -c 'xdg-open steam://rungameid/570'`
53:46 - INFO: Launching `flatpak-spawn --host /bin/sh -c 'xdg-open steam://rungameid/570'`
─────────────────────────────────────
57:14 - DEBUG: Starting page.kramo.Cartridges v2.8.3 (release)
57:14 - DEBUG: Python version: 3.11.9 (main, Nov 10 2011, 15:00:00) [GCC 13.2.0]
57:14 - DEBUG: Flatpak version: Flatpak 1.15.8
57:14 - DEBUG: Platform: Linux-6.8.8-300.fc40.x86_64-x86_64-with-glibc2.38
57:14 - DEBUG:  System: Linux
57:14 - DEBUG:  Node: fedora
57:14 - DEBUG:  Release: 6.8.8-300.fc40.x86_64
57:14 - DEBUG:  Version: #1 SMP PREEMPT_DYNAMIC Sat Apr 27 17:53:31 UTC 2024
57:14 - DEBUG:  Machine: x86_64
57:14 - DEBUG:  Processor: 
57:14 - DEBUG: ─────────────────────────────────────
57:14 - DEBUG: New store game Warsow (flatpak_net.warsow.Warsow)
57:14 - DEBUG: DisplayManager done for flatpak_net.warsow.Warsow
57:14 - DEBUG: New store game Proton 8.0 (steam_2348590)
57:14 - DEBUG: DisplayManager done for steam_2348590
57:14 - DEBUG: New store game Proton Experimental (steam_1493710)
57:14 - DEBUG: DisplayManager done for steam_1493710
57:14 - DEBUG: New store game Steam Linux Runtime 2.0 (soldier) (steam_1391110)
57:14 - DEBUG: DisplayManager done for steam_1391110
57:14 - DEBUG: New store game Proton EasyAntiCheat Runtime (steam_1826330)
57:14 - DEBUG: DisplayManager done for steam_1826330
57:14 - DEBUG: New store game Dota 2 (steam_570)
57:14 - DEBUG: DisplayManager done for steam_570
57:14 - DEBUG: New store game Steam Linux Runtime 3.0 (sniper) (steam_1628350)
57:14 - DEBUG: DisplayManager done for steam_1628350
57:14 - DEBUG: New store game Quake Live (steam_282440)
57:14 - DEBUG: DisplayManager done for steam_282440
57:14 - DEBUG: New store game Steamworks Common Redistributables (steam_228980)
57:14 - DEBUG: DisplayManager done for steam_228980
57:14 - DEBUG: New store game Steam Linux Runtime 1.0 (scout) (steam_1070560)
57:14 - DEBUG: DisplayManager done for steam_1070560
57:16 - INFO: Launching `flatpak-spawn --host /bin/sh -c 'xdg-open steam://rungameid/282440'`
─────────────────────────────────────
59:06 - DEBUG: Starting page.kramo.Cartridges v2.8.3 (release)
59:06 - DEBUG: Python version: 3.11.9 (main, Nov 10 2011, 15:00:00) [GCC 13.2.0]
59:06 - DEBUG: Flatpak version: Flatpak 1.15.8
59:06 - DEBUG: Platform: Linux-6.8.8-300.fc40.x86_64-x86_64-with-glibc2.38
59:06 - DEBUG:  System: Linux
59:06 - DEBUG:  Node: fedora
59:06 - DEBUG:  Release: 6.8.8-300.fc40.x86_64
59:06 - DEBUG:  Version: #1 SMP PREEMPT_DYNAMIC Sat Apr 27 17:53:31 UTC 2024
59:06 - DEBUG:  Machine: x86_64
59:06 - DEBUG:  Processor: 
59:06 - DEBUG: ─────────────────────────────────────
59:06 - DEBUG: New store game Warsow (flatpak_net.warsow.Warsow)
59:06 - DEBUG: DisplayManager done for flatpak_net.warsow.Warsow
59:06 - DEBUG: New store game Proton 8.0 (steam_2348590)
59:06 - DEBUG: DisplayManager done for steam_2348590
59:06 - DEBUG: New store game Proton Experimental (steam_1493710)
59:06 - DEBUG: DisplayManager done for steam_1493710
59:06 - DEBUG: New store game Steam Linux Runtime 2.0 (soldier) (steam_1391110)
59:06 - DEBUG: DisplayManager done for steam_1391110
59:06 - DEBUG: New store game Proton EasyAntiCheat Runtime (steam_1826330)
59:06 - DEBUG: DisplayManager done for steam_1826330
59:06 - DEBUG: New store game Dota 2 (steam_570)
59:06 - DEBUG: DisplayManager done for steam_570
59:06 - DEBUG: New store game Steam Linux Runtime 3.0 (sniper) (steam_1628350)
59:06 - DEBUG: DisplayManager done for steam_1628350
59:06 - DEBUG: New store game Quake Live (steam_282440)
59:06 - DEBUG: DisplayManager done for steam_282440
59:06 - DEBUG: New store game Steamworks Common Redistributables (steam_228980)
59:06 - DEBUG: DisplayManager done for steam_228980
59:06 - DEBUG: New store game Steam Linux Runtime 1.0 (scout) (steam_1070560)
59:06 - DEBUG: DisplayManager done for steam_1070560
59:08 - INFO: Launching `flatpak-spawn --host /bin/sh -c 'xdg-open steam://rungameid/570'`
01:01 - INFO: Launching `flatpak-spawn --host /bin/sh -c 'xdg-open steam://rungameid/570'`
kra-mo commented 5 months ago

I mean the game is running on the host so Cartridges really shouldn't have anything to do with this. It's an XWayland issue, but I'm not sure how it could be resolved. What output do you see in the terminal when you run Cartridges via flatpak run page.kramo.Cartridges and then try to launch the game?

pchmykh commented 5 months ago
~$ flatpak run page.kramo.Cartridges
root INFO - Launching `flatpak-spawn --host /bin/sh -c 'xdg-open steam://rungameid/570'`
INFO:root:https://github.com/flathub/com.valvesoftware.Steam/wiki
INFO:root:Will set XDG dirs prefix to /home/pchmykh/.var/app/com.valvesoftware.Steam
DEBUG:root:Checking input devices permissions
WARNING:root:Missing permissions for input devices
INFO:root:Overriding TZ to Europe/Minsk
steam.sh[2]: Running Steam on org.freedesktop.platform 23.08 64-bit
steam.sh[2]: STEAM_RUNTIME is enabled automatically
setup.sh[75]: Steam runtime environment up-to-date!
steam.sh[2]: Error: The unofficial Steam Flatpak app requires a correctly-configured desktop
session, which must provide the DISPLAY environment variable to the
D-Bus session bus activation environment.

On systems that use systemd --user, the DISPLAY environment variable must
also be present in the systemd --user activation environment.

This is usually achieved by running:

    dbus-update-activation-environment DISPLAY

during desktop environment startup.

For more details, please see:
https://github.com/ValveSoftware/steam-for-linux/issues/10554
/home/pchmykh/.var/app/com.valvesoftware.Steam/.local/share/Steam/steam.sh: line 85: XDG_CURRENT_DESKTOP: unbound variable
kra-mo commented 5 months ago

Yeah, I cannot reproduce the issue :/

It should inherit DISPLAY from your host, I'm not sure what the problem is here.

kra-mo commented 5 months ago

I mean I guess you could try running what it recommends, dbus-update-activation-environment DISPLAY although I have no idea what that does :D

pchmykh commented 5 months ago

Executing ~$ dbus-update-activation-environment DISPLAY with further relogin does the trick, but after reboot it comes back.

kra-mo commented 5 months ago

You should run it on desktop environment startup like it suggests.

https://wiki.archlinux.org/title/Autostarting

pchmykh commented 5 months ago

I have created and enabled user unit

~$ cat ~/.config/systemd/user/exportingDisplay.service 
[Unit]
Description=dbus-update-activation-environment DISPL
[Service]
ExecStart=dbus-update-activation-environment DISPLAY
[Install]
WantedBy=default.target

But it doesn't work for me. I can realize that it isn't Cartridges-related, so maybe you can advise me where I can fill issue? Is it about Steam or maybe Gnome-shell? Not very experienced user here.

kra-mo commented 5 months ago

If other apps work fine, probably Steam. You could file an issue on https://github.com/ValveSoftware/steam-for-linux/issues

kra-mo commented 5 months ago

Ah wait, you already did ^^

pchmykh commented 5 months ago

Not actually, but If you see related opened issue, please share. Thank you for your time!

smcv commented 3 months ago

I have tried to look into this from the Steam side, but from the information available so far, it looks like a problem with Cartridges' use of flatpak-spawn --host and/or xdg-open, or with system integration around the way that flatpak-session-helper is started.

When you get the error message "... must provide the DISPLAY environment variable ...", what that means is that the steam-runtime-check-requirements tool in the Steam Flatpak app tried to launch a new Flatpak "sub-sandbox" with the equivalent of flatpak-spawn) (Steam needs to do this for its user interface, for internal technical reasons), and found that in the new sub-sandbox, the DISPLAY environment variable is not set. This will break the Steam user interface completely, and will also break Proton and the Steam Linux Runtime container runtime framework, which is why steam-runtime-check-requirements wants to diagnose it early.

If the Cartridges Flatpak app wants to open a steam: URL on the host system, it would perhaps be more reliable if it used the xdg-desktop-portal interface for opening URLs. The easiest way to access that is to use gtk_show_uri_on_window() or g_app_info_launch_default_for_uri(), or their bindings in whatever language is used to implement this project (looks like Python if I'm skim-reading correctly). Those functions are designed to automatically "do the right thing": inside a Flatpak app, they call out to the portal, and in a non-sandboxed app, they run the URL handler directly (in this case that would mean Steam).

Flatpak has two background services that are relevant to these code paths. flatpak-session-helper is used to implement flatpak-spawn --host, and flatpak-portal is used to implement plain flatpak-spawn (without --host). For the way that Cartridges launches Steam, both of them need to be working as intended. If you were using gtk_show_uri_on_window() or g_app_info_launch_default_for_uri(), then only flatpak-portal would be in the critical path.

kra-mo commented 3 months ago

If the Cartridges Flatpak app wants to open a steam: URL on the host system, it would perhaps be more reliable if it used the xdg-desktop-portal interface for opening URLs

It's not doing that because it would create a dissonance between games opened via URI handlers and the rest. From a design POV, all games should launch the same way, eg. via a CLI. Because of that, even if this fixes the issue for Steam games, it won't if something like this ever comes up for other titles anyway.

kra-mo commented 3 months ago

Also, I have to add that this is not a widespread issue and probably only affects unconventional setups so I am not very concerned with it.