Ubuntu – Error on executing Steam Play game via command-line (Proton)

command linegamessteamwine

Recently Steam released Steam Play, which uses their fork of Wine hosted by Steam called Proton (GitHub) to allow us to play our complete games library under Linux. It creates wineprefixes for all of your games that don't already have a Linux port and works a far cry better than wine.

I'm trying to run Supreme Commander – Forged Alliance (Steam App ID: 9420) and play it on its unofficial multiplayer client, FAF. The game used to work with Wine, but now has a number of issues (for example, fullscreen doesn't work and high tendency to blackscreen in windowed). But it does work with Proton.

What I'm trying to do here is run this specific Steam game via terminal, not via Steam's GUI.

My intent isn't to circumvent Steam DRM, which running the games via terminal likely wouldn't accomplish anyways, but to run it with dynamic arguments. This will allow setting up multiplayer matches. This will be applied to other games in the future.


But I'm running into trouble when running in the terminal:

cd ~/.local/share/Steam/steamapps/common/Proton*
STEAM_COMPAT_DATA_PATH=/home/t/.local/share/Steam/steamapps/compatdata/9420 ./proton run /home/t/.local/share/Steam/steamapps/common/Supreme\ Commander\ Forged\ Alliance/bin/SupremeCommander.exe

I get an Error window: "Application load error P : 0000065615" and closing this simply brings me back to terminal with no extra output.
I've experimented with other games:

  1. Age of Empires 2 HD fails, but with a much more verbose error message window stating steam must be running, but I had Steam running at the time (and it would run if I clicked the play button in Steam).

  2. Bannerman: there is no message at all and even less terminal verbose.

  3. Shadow Complex Remastered gets an actual loader screen of the game, runs for about two seconds then crashes with an error:

    CAppInfoCacheReadFromDiskThread took 3 milliseconds to initialize
    CApplicationManagerPopulateThread took 7 milliseconds to initialize (will have waited on CAppInfoCacheReadFromDiskThread)
    

So no game seems to run successfully via this method.


Maybe some potential here UPDATE 3/10/2018:

WINEPREFIX="/home/t/fa-wineprefix/":"/home/t/.local/share/Steam/steamapps/common/Proton 3.7/dist/lib/wine winecfg"
PATH="/home/t/.local/share/Steam/steamapps/common/Proton 3.7/dist/bin/:$PATH"  
export WINEDLLPATH="/home/t/.local/share/Steam/steamapps/common/Proton 3.7/dist/lib64/wine:/home/t/.local/share/Steam/steamapps/common/Proton 3.7/dist/lib/wine"  
export LD_LIBRARY_PATH="/home/t/.local/share/Steam/steamapps/common/Proton 3.7/dist/lib64:/path/to/steam/steamapps/common/Proton 3.7/dist/lib:/usr/lib/steam:/usr/lib32/steam"
WINEPREFIX="/home/t/fa-wineprefix/"  "/home/t/.local/share/Steam/steamapps/common/Proton 3.7/dist/bin/./wine"   "/home/t/.local/share/Steam/steamapps/common/Supreme Commander Forged Alliance/bin/SupremeCommander.exe"

but this method fails at the last command with this error window:

Application load error P:0000065434

as well as some terminal output:

001f:err:module:load_builtin_dll failed to load .so lib for builtin L"winebus.sys": libudev.so.0: cannot open shared object file: No such file or directory
001f:err:ntoskrnl:ZwLoadDriver failed to create driver L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\WineBus": c0000142
001f:err:winedevice:create_driver failed to create driver L"WineBus": c0000142
0013:err:service:process_send_command service protocol error - failed to write pipe!
000d:fixme:service:scmdatabase_autostart_services Auto-start service L"WineBus" failed to start: 1114
0009:err:module:load_library somehow failed to load steamclient

so now we know more about the issue. it seems despite steam being running and every measure to let it know where steam is it does not find steam.

I also tried the same thing from inside the proton folder with the same result.


Some new potential here UPDATE 3/10/2018 :

the trick he mentions is creating a small python script protonRunner.py:

#!/usr/bin/env python

import os
import sys

home = os.environ["HOME"]
os.environ["STEAM_COMPAT_DATA_PATH"] = home + "/.local/share/Steam/steamapps/compatdata/9420"

run = "run"
exe = "\"" + home + "/.local/share/Steam/steamapps/common/Supreme Commander Forged Alliance/bin/SupremeCommander.exe\""

cmd = "\"" + home + "/.local/share/Steam/steamapps/common/Proton 3.7/proton\" " + run + " " + exe

for arg in sys.argv[1:]:
    cmd += " " + arg

os.system(cmd)

supcomFA.desktop:

[Desktop Entry]
Name=SupremeCommander
Exec=python $HOME/.local/share/Steam/steamapps/common/Proton\ 3.7/protonRunner.py
Icon=/home/t/.local/share/icons/supcom.png
Type=Application
Encoding=UTF-8
Version=1.0
Terminal=true

doing this accomplishes the same error message:

Application load error P:0000065434


TL;DR: How to run a Windows Steam game (that manages to run via Proton on Linux) from the terminal.

Best Answer

Here's an experiment that may help you get the answer. For convenience, I'll refer to your default Steam library location as $STEAM (the default is ~/.local/share/Steam/). Proton is installed by default to $STEAM/steamapps/common/Proton 3.7, I'll call this $PROTON.

So, when I tried running The Witcher, Steam ran this command:

"$PROTON/dist/bin/wine-preloader" "$PROTON/dist/bin/wine" "Z:\$STEAM\steamapps\common\The Witcher Enhanced Edition\System\witcher.exe"

Where $STEAM has backslashes instead of slashes, as it's a Windows path. In addition, it set something like 70 environment variables (related to Wine, Steam, various hardware/drivers, libraries, etc.). A single variable, WINESERVERSOCKET referred to the wine server started for this instance. If I omitted this variable and used all the rest, I could start the game from the command line.

Steps:

  1. Replace $PROTON/dist/bin/wine-preloader with a wrapper script that saves the environment somewhere:

    PROTON="$HOME/.local/share/Steam/steamapps/common/Proton 3.7" # adjust to your settings
    mv "$PROTON/dist/bin/wine-preloader" "$PROTON/dist/bin/wine-preloader-orig"
    printf "%s\n" '#! /bin/sh' 'env --null | grep -vz WINESERVERSOCKET > ~/env' > "$PROTON/dist/bin/wine-preloader"
    printf 'exec %q "$@"\n' "$PROTON/dist/bin/wine-preloader-orig" >> "$PROTON/dist/bin/wine-preloader"
    chmod +x "$PROTON/dist/bin/wine-preloader"
    

    The script is essentially this:

    #! /bin/sh
    env --null | grep -vz WINESERVERSOCKET= > ~/env
    printf "%s\0" "$0"-orig "$@" > ~/cmd
    exec /home/user/.local/share/Steam/steamapps/common/Proton\ 3.7/dist/bin/wine-preloader-orig "$@"
    

    It saves the environment, except for WINESERVERSOCKET, in ~/env, the command to run and arguments in ~/cmd and runs the actual file with the arguments provided. It uses ASCII null characters to separate everything, since the actual environment variables may contain newlines.

    Note that I save the command with -orig added for convenience.

  2. Run the game from the Steam GUI. The wrapper script will create these files.

  3. You can load the environment and run the command from these files. In bash

    mapfile -d '' -t env < ~/env
    mapfile -d '' -t cmd < ~/cmd
    env "${env[@]}" "${cmd[@]}"
    

    -d '' here tells bash the files use the ASCII null character as delimiter.

This much was sufficient for The Witcher to run for me. All of those environment variables probably won't be necessary. I leave it to you to test which aren't.


Of course, all of these might be completely unnecessary. Looking at Steam's command-line options, we have:

-applaunch <appID> [launch parameters]  Launches an Game or Application through Steam.

And when I ran:

steam -applaunch 20900 foo bar

the Wine command was:

"$PROTON/dist/bin/wine" "Z:\$STEAM\steamapps\common\The Witcher Enhanced Edition\System\witcher.exe" foo bar

So Steam did pass on foo and bar as arguments to the game. This might be all you need.

Related Question