Repository: lutris/lutris

Issue:
Lutris 0.5.10 fails to install .Net Framework 4.8 (error code 256)
### Bug description

On Lutris 0.5.10, when trying to install dotnet48 intro a wine prefix, it will fail with error code 256 because the %AppData% environment variable is not being set.

Downgrading to Lutris 0.5.9.1 does not have this issue, which I've been able to verify among a few users. 

This was tested on multiple wine runners such as lutris-wine-7.2, lutris-wine-7.1, and custom builds, so I'm confident it's not wine-runner related. I've also tried updating winetricks manually, which did not make a difference. I also tried adding `return_code: 256` to a personal copy of the install script, but then it just errors on something else.

### How to Reproduce

Steps to reproduce the behavior:
1. Open Lutris
2. Open a Wine-runner based installer that will require .Net Framework 4.8 (ex: <https://lutris.net/games/install/29349/view>)
3. Proceed with installation
4. Lutris will nearly immediately error out due to .Net Framework failing.

### Expected behavior

I expected Lutris 0.5.10 to work like 0.5.9.1 and prior versions on less bleeding-edge distributions.

Initially I thought this might be related to Fedora Nobara and contacted GloriousEggroll to report it, but upon testing, he found that downgrading Lutris to an earlier build resolved the issue.,

### Log output

```shell
[$USER@razer-linux ~]$ lutris -d
INFO     2022-04-02 23:08:32,524 [startup.init_lutris:173]:Starting Lutris 0.5.10
WARNING  2022-04-02 23:08:32,548 [libretro.get_libretro_cores:24]:No folder at /home/$USER/.local/share/lutris/runners/retroarch/
INFO     2022-04-02 23:08:32,579 [startup.check_driver:57]:Using NVIDIA drivers 470.103.01 for x86_64
INFO     2022-04-02 23:08:32,579 [startup.check_driver:61]:GPU: Unknown
INFO     2022-04-02 23:08:32,579 [startup.check_driver:77]:GPU: 10DE:1199 1A58:6749 (nvidia drivers)
INFO     2022-04-02 23:08:32,580 [startup.check_driver:77]:GPU: 8086:0416 8086:0416 (i915 drivers)
MESA-INTEL: warning: Haswell Vulkan support is incomplete
INFO     2022-04-02 23:08:32,656 [startup.update_runtime:213]:Startup complete
DEBUG    2022-04-02 23:08:32,787 [lutriswindow.update_store:437]:Showing 0 games
DEBUG    2022-04-02 23:08:35,261 [application.show_window:332]:Showing window AddGamesWindow{}
DEBUG    2022-04-02 23:08:41,670 [http.get:83]:GET https://lutris.net/api/games?search=final+fantasy+xiv&with-installers=True
DEBUG    2022-04-02 23:08:43,552 [api.get_game_installers:160]:Fetching installer https://lutris.net/api/installers/final-fantasy-xiv-online
DEBUG    2022-04-02 23:08:43,553 [http.get:83]:GET https://lutris.net/api/installers/final-fantasy-xiv-online
DEBUG    2022-04-02 23:08:44,012 [application.show_window:332]:Showing window InstallerWindowfinal-fantasy-xiv-online
DEBUG    2022-04-02 23:08:44,013 [application.on_app_window_destroyed:350]:Removed window AddGamesWindow{}
DEBUG    2022-04-02 23:08:47,651 [displayconfig.get_current_resolution:624]:Retrieving current resolution
DEBUG    2022-04-02 23:08:48,886 [interpreter.get_extras:159]:Checking if service provide extra files
DEBUG    2022-04-02 23:08:48,886 [installer.prepare_game_files:146]:No service to retrieve files from
DEBUG    2022-04-02 23:08:48,894 [interpreter.create_game_folder:181]:Creating destination path /home/$USER/Games/final-fantasy-xiv-online
DEBUG    2022-04-02 23:08:50,226 [downloader.start:65]:⬇ https://kamori.goats.dev/Proxy/Update/Release/Setup.exe
DEBUG    2022-04-02 23:08:51,416 [downloader.download_cb:125]:Finished downloading https://kamori.goats.dev/Proxy/Update/Release/Setup.exe
INFO     2022-04-02 23:08:51,730 [file_box.on_download_complete:252]:Download completed
DEBUG    2022-04-02 23:08:51,730 [files_box.on_file_available:93]:launchersetup is available
INFO     2022-04-02 23:08:51,730 [files_box.on_file_available:99]:All files available
INFO     2022-04-02 23:08:51,731 [installerwindow.on_files_available:463]:All files are available, continuing install
DEBUG    2022-04-02 23:08:51,735 [interpreter._iter_commands:317]:Installer command: {'task': {'arch': 'win64', 'install_gecko': False, 'install_mono': False, 'name': 'create_prefix', 'prefix': '$GAMEDIR'}}
INFO     2022-04-02 23:08:51,741 [wine.create_prefix:96]:Creating a win64 prefix in /home/$USER/Games/final-fantasy-xiv-online
DEBUG    2022-04-02 23:08:51,747 [system.execute:56]:Executing /home/$USER/.local/share/lutris/runners/wine/lutris-7.1-x86_64/bin/wineboot
DEBUG    2022-04-02 23:08:51,747 [system.execute:62]:WINEARCH=win64 WINEPREFIX=/home/$USER/Games/final-fantasy-xiv-online WINEDLLOVERRIDES=winemenubuilder= WINE_MONO_CACHE_DIR=/home/$USER/.local/share/lutris/runners/wine/lutris-7.1-x86_64/mono WINE_GECKO_CACHE_DIR=/home/$USER/.local/share/lutris/runners/wine/lutris-7.1-x86_64/gecko WINE_SKIP_GECKO_INSTALLATION=1 WINE_SKIP_MONO_INSTALLATION=1
INFO     2022-04-02 23:09:06,828 [wine.create_prefix:147]:win64 Prefix created in /home/$USER/Games/final-fantasy-xiv-online
DEBUG    2022-04-02 23:09:06,856 [interpreter._iter_commands:317]:Installer command: {'task': {'arch': 'win64', 'key': 'background', 'name': 'set_regedit', 'path': 'HKEY_CURRENT_USER\\Control Panel\\Colors\\', 'prefix': '$GAMEDIR', 'type': 'REG_SZ', 'value': '0 0 0'}}
DEBUG    2022-04-02 23:09:06,862 [wine.set_regedit:47]:Setting [HKEY_CURRENT_USER\Control Panel\Colors\]:background="0 0 0"
DEBUG    2022-04-02 23:09:06,880 [wine.use_lutris_runtime:115]:/home/$USER/.local/share/lutris/runners/wine/lutris-7.1-x86_64/bin/wine64 is provided by Lutris, using runtime
DEBUG    2022-04-02 23:09:07,687 [system.execute:56]:Executing /home/$USER/.local/share/lutris/runners/wine/lutris-7.1-x86_64/bin/wine64 regedit /S /home/$USER/.cache/lutris/winekeys.reg
DEBUG    2022-04-02 23:09:07,688 [system.execute:62]:WINEARCH=win64 WINE=/home/$USER/.local/share/lutris/runners/wine/lutris-7.1-x86_64/bin/wine64 WINEPREFIX=/home/$USER/Games/final-fantasy-xiv-online LD_LIBRARY_PATH=/home/$USER/.local/share/lutris/runners/wine/lutris-7.1-x86_64/lib:/home/$USER/.local/share/lutris/runners/wine/lutris-7.1-x86_64/lib64:/lib64:/lib:/usr/lib64/pipewire-0.3/jack:/usr/lib64/qt5-qtwebengine-freeworld:/usr/lib64/iscsi:/usr/lib:/usr/lib64:/home/$USER/.local/share/lutris/runtime/Ubuntu-18.04-i686:/home/$USER/.local/share/lutris/runtime/steam/i386/lib/i386-linux-gnu:/home/$USER/.local/share/lutris/runtime/steam/i386/lib:/home/$USER/.local/share/lutris/runtime/steam/i386/usr/lib/i386-linux-gnu:/home/$USER/.local/share/lutris/runtime/steam/i386/usr/lib:/home/$USER/.local/share/lutris/runtime/Ubuntu-18.04-x86_64:/home/$USER/.local/share/lutris/runtime/steam/amd64/lib/x86_64-linux-gnu:/home/$USER/.local/share/lutris/runtime/steam/amd64/lib:/home/$USER/.local/share/lutris/runtime/steam/amd64/usr/lib/x86_64-linux-gnu:/home/$USER/.local/share/lutris/runtime/steam/amd64/usr/lib
DEBUG    2022-04-02 23:09:08,487 [interpreter._iter_commands:317]:Installer command: {'task': {'app': 'dotnet48 vcrun2019 win10', 'name': 'winetricks', 'prefix': '$GAMEDIR'}}
DEBUG    2022-04-02 23:09:08,522 [wine.use_lutris_runtime:115]:/home/$USER/.local/share/lutris/runners/wine/lutris-7.1-x86_64/bin/wine is provided by Lutris, using runtime
ERROR    2022-04-02 23:09:09,205 [wine.game_exe:521]:The game doesn't have an executable
DEBUG    2022-04-02 23:09:09,205 [command.start:141]:__GL_SHADER_DISK_CACHE="1"
DEBUG    2022-04-02 23:09:09,206 [command.start:141]:__GL_SHADER_DISK_CACHE_PATH="/home/$USER/.cache/lutris/shaders/wine"
DEBUG    2022-04-02 23:09:09,206 [command.start:141]:DRI_PRIME="1"
DEBUG    2022-04-02 23:09:09,206 [command.start:141]:LD_LIBRARY_PATH="/home/$USER/.local/share/lutris/runners/wine/lutris-7.1-x86_64/lib:/home/$USER/.local/share/lutris/runners/wine/lutris-7.1-x86_64/lib64:/lib64:/lib:/usr/lib64/pipewire-0.3/jack:/usr/lib64/qt5-qtwebengine-freeworld:/usr/lib64/iscsi:/usr/lib:/usr/lib64:/home/$USER/.local/share/lutris/runtime/Ubuntu-18.04-i686:/home/$USER/.local/share/lutris/runtime/steam/i386/lib/i386-linux-gnu:/home/$USER/.local/share/lutris/runtime/steam/i386/lib:/home/$USER/.local/share/lutris/runtime/steam/i386/usr/lib/i386-linux-gnu:/home/$USER/.local/share/lutris/runtime/steam/i386/usr/lib:/home/$USER/.local/share/lutris/runtime/Ubuntu-18.04-x86_64:/home/$USER/.local/share/lutris/runtime/steam/amd64/lib/x86_64-linux-gnu:/home/$USER/.local/share/lutris/runtime/steam/amd64/lib:/home/$USER/.local/share/lutris/runtime/steam/amd64/usr/lib/x86_64-linux-gnu:/home/$USER/.local/share/lutris/runtime/steam/amd64/usr/lib"
DEBUG    2022-04-02 23:09:09,206 [command.start:141]:WINEDEBUG="-all"
DEBUG    2022-04-02 23:09:09,206 [command.start:141]:DXVK_LOG_LEVEL="none"
DEBUG    2022-04-02 23:09:09,206 [command.start:141]:WINEARCH="win64"
DEBUG    2022-04-02 23:09:09,206 [command.start:141]:WINE="/home/$USER/.local/share/lutris/runners/wine/lutris-7.1-x86_64/bin/wine"
DEBUG    2022-04-02 23:09:09,206 [command.start:141]:WINE_MONO_CACHE_DIR="/home/$USER/.local/share/lutris/runners/wine/lutris-7.2-x86_64/mono"
DEBUG    2022-04-02 23:09:09,206 [command.start:141]:WINE_GECKO_CACHE_DIR="/home/$USER/.local/share/lutris/runners/wine/lutris-7.2-x86_64/gecko"
DEBUG    2022-04-02 23:09:09,206 [command.start:141]:GST_PLUGIN_SYSTEM_PATH_1_0="/home/$USER/.local/share/lutris/runners/wine/lutris-7.2-x86_64/lib64/gstreamer-1.0/:/home/$USER/.local/share/lutris/runners/wine/lutris-7.2-x86_64/lib/gstreamer-1.0/"
DEBUG    2022-04-02 23:09:09,206 [command.start:141]:WINEPREFIX="/home/$USER/Games/final-fantasy-xiv-online"
DEBUG    2022-04-02 23:09:09,206 [command.start:141]:WINEESYNC="1"
DEBUG    2022-04-02 23:09:09,207 [command.start:141]:WINEFSYNC="1"
DEBUG    2022-04-02 23:09:09,207 [command.start:141]:WINE_FULLSCREEN_FSR="1"
DEBUG    2022-04-02 23:09:09,207 [command.start:141]:DXVK_NVAPIHACK="0"
DEBUG    2022-04-02 23:09:09,207 [command.start:141]:DXVK_ENABLE_NVAPI="1"
DEBUG    2022-04-02 23:09:09,207 [command.start:141]:PROTON_BATTLEYE_RUNTIME="/home/$USER/.local/share/lutris/runtime/battleye_runtime"
DEBUG    2022-04-02 23:09:09,207 [command.start:141]:PROTON_EAC_RUNTIME="/home/$USER/.local/share/lutris/runtime/eac_runtime"
DEBUG    2022-04-02 23:09:09,207 [command.start:141]:WINEDLLOVERRIDES="winemenubuilder="
DEBUG    2022-04-02 23:09:09,207 [command.start:141]:PYTHONPATH="/usr/lib/lutris:/usr/bin:/usr/lib64/python310.zip:/usr/lib64/python3.10:/usr/lib64/python3.10/lib-dynload:/usr/lib64/python3.10/site-packages:/usr/lib/python3.10/site-packages"
DEBUG    2022-04-02 23:09:09,207 [command.start:141]:LUTRIS_GAME_UUID="a81510d2-f143-4491-b0d6-6747d9fb6801"
Started initial process 3588 from /home/$USER/.local/share/lutris/runtime/winetricks/winetricks --unattended dotnet48 vcrun2019 win10
Start monitoring process.
------------------------------------------------------
warning: Your version of wine 4.8-22663-gcb3e2c222f5 is no longer supported upstream. You should upgrade to 5.x
------------------------------------------------------
Executing mkdir -p /home/$USER/Games
------------------------------------------------------
warning: You are using a 64-bit WINEPREFIX. Note that many verbs only install 32-bit versions of packages. If you encounter p$USERlems, please retest in a clean 32-bit WINEPREFIX before reporting a bug.
------------------------------------------------------
------------------------------------------------------
WINEPREFIX INFO:
Drive C: total 0
drwxrwxr-x 1 $USER $USER 110 Apr  2 23:08 .
drwxrwxr-x 1 $USER $USER 126 Apr  2 23:09 ..
drwxrwxr-x 1 $USER $USER  18 Apr  2 23:08 ProgramData
drwxrwxr-x 1 $USER $USER 118 Apr  2 23:08 Program Files
drwxrwxr-x 1 $USER $USER 118 Apr  2 23:08 Program Files (x86)
drwxrwxr-x 1 $USER $USER  18 Apr  2 23:08 users
drwxrwxr-x 1 $USER $USER 484 Apr  2 23:09 windows

Registry info:
/home/$USER/Games/final-fantasy-xiv-online/system.reg:#arch=win64
/home/$USER/Games/final-fantasy-xiv-online/userdef.reg:#arch=win64
/home/$USER/Games/final-fantasy-xiv-online/user.reg:#arch=win64
------------------------------------------------------
------------------------------------------------------
warning: /home/$USER/.local/share/lutris/runners/wine/lutris-7.1-x86_64/bin/wine cmd.exe /c echo '%AppData%' returned empty string, error message "" 
------------------------------------------------------
Monitored process exited.
Initial process has exited (return code: 256)
All processes have quit
Exit with return code 256
DEBUG    2022-04-02 23:09:09,804 [command.on_stop:195]:Process 3586 has terminated with code 256
DEBUG    2022-04-02 23:09:10,214 [commands._monitor_task:449]:Return code: 256
ERROR    2022-04-02 23:09:10,215 [errors.__init__:18]:Command exited with code 256
None
```


### System Information

```shell
[System]
OS:              Fedora Linux 35 
Arch:            x86_64
Kernel:          5.16.18-201.fsync.fc35.x86_64
Desktop:         GNOME
Display Server:  x11

[CPU]
Vendor:          GenuineIntel
Model:           Intel(R) Core(TM) i7-4702HQ CPU @ 2.20GHz
Physical cores:  4
Logical cores:   8

[Memory]
RAM:             7.7 GB
Swap:            7.7 GB

[Graphics]
Vendor:          Mesa/X.org
OpenGL Renderer: llvmpipe (LLVM 13.0.0, 256 bits)
OpenGL Version:  4.5 (Compatibility Profile) Mesa 22.1.0-devel
OpenGL Core:     4.5 (Core Profile) Mesa 22.1.0-devel
OpenGL ES:       OpenGL ES 3.2 Mesa 22.1.0-devel
Vulkan:          Supported
```


### Media (optional)

_No response_

### Checklist:

- [X] I'm not asking for support with a game or the wine runner.
- [X] I have followed the above mentioned guides and have all the graphics and wine dependencies installed.
- [X] I have checked for existing issues that describe my problem prior to opening this one.
- [X] I understand that improperly formatted bug reports may be closed without explanation.


Discussion:
did bisect, https://github.com/lutris/lutris/commit/4387365c117ec20ac25555d6f801469d44acbf85 is the cause. Reverting that commit fixes it

Resolving patch:
diff --git a/lutris/runners/commands/wine.py b/lutris/runners/commands/wine.py
--- a/lutris/runners/commands/wine.py
+++ b/lutris/runners/commands/wine.py
@@ -299,7 +299,7 @@ def wineexec(  # noqa: C901
     wine.prelaunch()
 
     if blocking:
-        return system.execute(command_parameters, env=wineenv, cwd=working_dir)
+        return system.execute(command_parameters, env=baseenv, cwd=working_dir)
 
     command = MonitoredCommand(
         command_parameters,


Test patch: