Repository: lutris/lutris

Issue:
Winetricks doesn't launch when game's version of wine mismatches system-wide version
If the user has wine installed system-wide, has a game installed in Lutris with Runtime enabled, and that game is using a version of wine that doesn't match the system version (for example,  3.14 with staging patches when on the system there is staging-3.15 and vice versa), the Winetricks will fail to start with the folllowing output

> WINEPREFIX INFO:
> Drive C: total 28
> drwxr-xr-x  6 alex alex 4096 авг 31 15:19 .
> drwxr-xr-x  4 alex alex 4096 сен  4 18:09 ..
> drwxr-xr-x  4 alex alex 4096 сен  4 15:28 ProgramData
> drwxr-xr-x  8 alex alex 4096 авг 31 15:21 Program Files
> drwxr-xr-x  4 alex alex 4096 авг 31 15:19 users
> drwxr-xr-x 16 alex alex 4096 сен  1 08:28 windows
> -rw-r--r--  1 alex alex    9 авг 31 15:19 .windows-serial
> 
> Registry info:
> /home/alex/Games/the-sims/system.reg:#arch=win32
> /home/alex/Games/the-sims/userdef.reg:#arch=win32
> /home/alex/Games/the-sims/user.reg:#arch=win32

But if the users gets the versions match, OR removes wine from their system, OR disables Runtime, the issue will disappear.
Removing the runtime completely (except for winetricks) while Lutris is still running doesn't change anything. Actually, getting rid of winetricks too doesn't change the error either.
This affects a lot of users (as can be seen in #1085), and it's not specific to the platform used.


Discussion:
I can confirm what you described. I've played around a bit and it can be replicated when running winetricks outside of Lutris but with the same environment variables set (Which makes it a bit easier to debug). [The log output](https://gist.github.com/Medath/980433bbdd0b77aa639a5bdc1d2d4b9a) reveals a bit more info than when running it through Lutris for some reason, but shows the exact same behaviour otherwise (meaning it works without LD_LIBRARY_PATH or with the same wine version or when system wine is not installed). Line 20 seems very interesting and shows the good old `wine client error:0: version mismatch 560/557` error.

Now that I see it, when launching a wine game Lutris puts the libs of the wine runner at the very beginning of LD_LIBRARY_PATH but it doesn't do it when launching winetricks. When I add `/home/<username>/.local/share/lutris/runners/wine/<wine_version>/lib:/home/<username>/.local/share/lutris/runners/wine/<wine_version>/lib64` to the very beginning of LD_LIBRARY_PATH, winetricks launches just fine for me. So it seems like this is basically #903 but with winetricks.
Also adding to this, I am not able to reproduce this issue on Ubuntu at all. I assume this also applies to Ubuntu-based distributions but I didn't test it. I was able to reproduce it very consistently on Solus (native) and on Manjaro (VM; Manjaro still ships 0.4.18, but I used master).
I guess that if I want to work on this issue at all, I'll have to install Arch. I have some space reserved on my new NVMe drive for that but no timeframe for when I'll do it.

Resolving patch:
diff --git a/lutris/runners/wine.py b/lutris/runners/wine.py
--- a/lutris/runners/wine.py
+++ b/lutris/runners/wine.py
@@ -256,6 +256,8 @@ def wineexec(executable, args="", wine_path=None, prefix=None, arch=None,
     if use_lutris_runtime(wine_path=wineenv['WINE'], force_disable=disable_runtime):
         if WINE_DIR in wine_path:
             wine_root_path = os.path.dirname(os.path.dirname(wine_path))
+        elif WINE_DIR in winetricks_wine:
+            wine_root_path = os.path.dirname(os.path.dirname(winetricks_wine))
         else:
             wine_root_path = None
         wineenv['LD_LIBRARY_PATH'] = ':'.join(runtime.get_paths(


Test patch: