Repository: lutris/lutris

Issue:
"Run EXE inside Wine prefix" ignores Envs
### Bug description

"Run EXE inside Wine prefix" doesn't use envs specified on the system options tab for that game

### How to Reproduce

1. Set some envs for the game (like LANG for a Japanese game that won't display fonts correctly otherwise)
2. Run the main exec through "Play" to verify envs work in that mode
3. Use "run EXE inside Wine prefix" command to launch any exe inside that prefix - envs will not get used

### Expected behavior

Said option should use exact same runner options as the main executable

### Log output

```shell
INFO     2022-05-06 18:59:03,610 [startup.init_lutris:173]:Starting Lutris 0.5.10.1
WARNING  2022-05-06 18:59:03,635 [libretro.get_libretro_cores:24]:No folder at /home/nekoinemo/.local/share/lutris/runners/retroarch/
DEBUG    2022-05-06 18:59:03,641 [xrandr._get_vidmodes:15]:Retrieving video modes from XrandR
INFO     2022-05-06 18:59:03,952 [startup.check_driver:57]:Using NVIDIA drivers 510.60.02 for x86_64
INFO     2022-05-06 18:59:03,952 [startup.check_driver:61]:GPU: NVIDIA GeForce GTX 1660 Ti
INFO     2022-05-06 18:59:03,952 [startup.check_driver:77]:GPU: 10DE:2191 1462:129B (nvidia drivers)
INFO     2022-05-06 18:59:03,952 [startup.check_driver:77]:GPU: 8086:3E9B 1462:129B (i915 drivers)
INFO     2022-05-06 18:59:03,987 [startup.update_runtime:213]:Startup complete
DEBUG    2022-05-06 18:59:04,060 [lutriswindow.update_store:437]:Showing 4 games
DEBUG    2022-05-06 18:59:08,459 [xrandr._get_vidmodes:15]:Retrieving video modes from XrandR
DEBUG    2022-05-06 18:59:08,843 [xrandr._get_vidmodes:15]:Retrieving video modes from XrandR
DEBUG    2022-05-06 18:59:09,128 [xrandr._get_vidmodes:15]:Retrieving video modes from XrandR
DEBUG    2022-05-06 18:59:09,412 [xrandr._get_vidmodes:15]:Retrieving video modes from XrandR
DEBUG    2022-05-06 18:59:09,755 [application.show_window:332]:Showing window EditGameConfigDialog5
DEBUG    2022-05-06 18:59:14,270 [game.save:268]:Saving Jinkou Gakuen 2 (wine) with config ID jinkou-gakuen-2-1651851289
DEBUG    2022-05-06 18:59:14,270 [config.save:229]:Saving LutrisConfig(level=game, game_config_id=jinkou-gakuen-2-1651851289, runner=wine) config to /home/nekoinemo/.config/lutris/games/jinkou-gakuen-2-1651851289.yml
DEBUG    2022-05-06 18:59:14,317 [application.on_app_window_destroyed:350]:Removed window EditGameConfigDialog5
DEBUG    2022-05-06 18:59:21,612 [wine.use_lutris_runtime:115]:/home/nekoinemo/.local/share/lutris/runners/wine/lutris-fshack-7.2-x86_64/bin/wine is provided by Lutris, using runtime
DEBUG    2022-05-06 18:59:22,078 [command.start:141]:__GL_SHADER_DISK_CACHE="1"
DEBUG    2022-05-06 18:59:22,078 [command.start:141]:__GL_SHADER_DISK_CACHE_PATH="/home/nekoinemo/mnt"
DEBUG    2022-05-06 18:59:22,078 [command.start:141]:DRI_PRIME="1"
DEBUG    2022-05-06 18:59:22,078 [command.start:141]:VK_ICD_FILENAMES="/usr/share/vulkan/icd.d/nvidia_icd.json"
DEBUG    2022-05-06 18:59:22,078 [command.start:141]:LD_LIBRARY_PATH="/home/nekoinemo/.local/share/lutris/runners/wine/lutris-fshack-7.2-x86_64/lib:/home/nekoinemo/.local/share/lutris/runners/wine/lutris-fshack-7.2-x86_64/lib64:/usr/lib:/usr/lib32:/usr/lib/openmpi:/usr/lib/libfakeroot:/usr/lib64:/home/nekoinemo/.local/share/lutris/runtime/Ubuntu-18.04-i686:/home/nekoinemo/.local/share/lutris/runtime/steam/i386/lib/i386-linux-gnu:/home/nekoinemo/.local/share/lutris/runtime/steam/i386/lib:/home/nekoinemo/.local/share/lutris/runtime/steam/i386/usr/lib/i386-linux-gnu:/home/nekoinemo/.local/share/lutris/runtime/steam/i386/usr/lib:/home/nekoinemo/.local/share/lutris/runtime/Ubuntu-18.04-x86_64:/home/nekoinemo/.local/share/lutris/runtime/steam/amd64/lib/x86_64-linux-gnu:/home/nekoinemo/.local/share/lutris/runtime/steam/amd64/lib:/home/nekoinemo/.local/share/lutris/runtime/steam/amd64/usr/lib/x86_64-linux-gnu:/home/nekoinemo/.local/share/lutris/runtime/steam/amd64/usr/lib"
DEBUG    2022-05-06 18:59:22,078 [command.start:141]:WINEDEBUG="-all"
DEBUG    2022-05-06 18:59:22,078 [command.start:141]:DXVK_LOG_LEVEL="none"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:WINEARCH="win64"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:WINE="/home/nekoinemo/.local/share/lutris/runners/wine/lutris-fshack-7.2-x86_64/bin/wine"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:WINE_MONO_CACHE_DIR="/home/nekoinemo/.local/share/lutris/runners/wine/lutris-fshack-7.2-x86_64/mono"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:WINE_GECKO_CACHE_DIR="/home/nekoinemo/.local/share/lutris/runners/wine/lutris-fshack-7.2-x86_64/gecko"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:GST_PLUGIN_SYSTEM_PATH_1_0="/home/nekoinemo/.local/share/lutris/runners/wine/lutris-fshack-7.2-x86_64/lib64/gstreamer-1.0/:/home/nekoinemo/.local/share/lutris/runners/wine/lutris-fshack-7.2-x86_64/lib/gstreamer-1.0/"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:WINEPREFIX="/home/nekoinemo/Games/jinkou-gakuen-2/wine"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:WINEESYNC="1"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:WINEFSYNC="1"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:WINE_FULLSCREEN_FSR="1"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:DXVK_NVAPIHACK="0"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:DXVK_ENABLE_NVAPI="1"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:PROTON_BATTLEYE_RUNTIME="/home/nekoinemo/.local/share/lutris/runtime/battleye_runtime"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:PROTON_EAC_RUNTIME="/home/nekoinemo/.local/share/lutris/runtime/eac_runtime"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:WINEDLLOVERRIDES="d3d10core,d3d11,d3d12,d3d9,d3dcompiler_33,d3dcompiler_34,d3dcompiler_35,d3dcompiler_36,d3dcompiler_37,d3dcompiler_38,d3dcompiler_39,d3dcompiler_40,d3dcompiler_41,d3dcompiler_42,d3dcompiler_43,d3dcompiler_46,d3dcompiler_47,d3dx10,d3dx10_33,d3dx10_34,d3dx10_35,d3dx10_36,d3dx10_37,d3dx10_38,d3dx10_39,d3dx10_40,d3dx10_41,d3dx10_42,d3dx10_43,d3dx11_42,d3dx11_43,d3dx9_24,d3dx9_25,d3dx9_26,d3dx9_27,d3dx9_28,d3dx9_29,d3dx9_30,d3dx9_31,d3dx9_32,d3dx9_33,d3dx9_34,d3dx9_35,d3dx9_36,d3dx9_37,d3dx9_38,d3dx9_39,d3dx9_40,d3dx9_41,d3dx9_42,d3dx9_43,dxgi,nvapi,nvapi64,nvml=n;winemenubuilder="
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:LANG="en_GB.UTF-8"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:SHELL="/bin/zsh"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:XDG_SESSION_PATH="/org/freedesktop/DisplayManager/Session0"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:GTK_IM_MODULE="fcitx5"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:I3SOCK="/run/user/1000/i3/ipc-socket.1201"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:SSH_AUTH_SOCK="/run/user/1000/keyring/ssh"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:INPUT_METHOD="fcitx5"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:XMODIFIERS="@im=fcitx5"
DEBUG    2022-05-06 18:59:22,079 [command.start:141]:DESKTOP_SESSION="i3"
DEBUG    2022-05-06 18:59:22,080 [command.start:141]:EDITOR="mousepad"
DEBUG    2022-05-06 18:59:22,080 [command.start:141]:DXVK_CONFIG_FILE="/home/nekoinemo/.config/dxvk.conf"
DEBUG    2022-05-06 18:59:22,080 [command.start:141]:GTK_MODULES="canberra-gtk-module"
DEBUG    2022-05-06 18:59:22,080 [command.start:141]:XDG_SEAT="seat0"
DEBUG    2022-05-06 18:59:22,080 [command.start:141]:PWD="/home/nekoinemo"
DEBUG    2022-05-06 18:59:22,080 [command.start:141]:LOGNAME="nekoinemo"
DEBUG    2022-05-06 18:59:22,080 [command.start:141]:XDG_SESSION_DESKTOP="i3"
DEBUG    2022-05-06 18:59:22,080 [command.start:141]:XDG_SESSION_TYPE="x11"
DEBUG    2022-05-06 18:59:22,080 [command.start:141]:XAUTHORITY="/home/nekoinemo/.Xauthority"
DEBUG    2022-05-06 18:59:22,080 [command.start:141]:DESKTOP_STARTUP_ID="i3/urxvt/1201-189-nagato_TIME495747033"
DEBUG    2022-05-06 18:59:22,080 [command.start:141]:XDG_GREETER_DATA_DIR="/var/lib/lightdm-data/nekoinemo"
DEBUG    2022-05-06 18:59:22,080 [command.start:141]:MOTD_SHOWN="pam"
DEBUG    2022-05-06 18:59:22,080 [command.start:141]:HOME="/home/nekoinemo"
DEBUG    2022-05-06 18:59:22,080 [command.start:141]:XDG_CURRENT_DESKTOP="i3"
DEBUG    2022-05-06 18:59:22,080 [command.start:141]:MAIN_MONITOR="eDP-1-1"
DEBUG    2022-05-06 18:59:22,080 [command.start:141]:XDG_SEAT_PATH="/org/freedesktop/DisplayManager/Seat0"
DEBUG    2022-05-06 18:59:22,080 [command.start:141]:STEAM_FRAME_FORCE_CLOSE="1"
DEBUG    2022-05-06 18:59:22,080 [command.start:141]:XDG_SESSION_CLASS="user"
DEBUG    2022-05-06 18:59:22,080 [command.start:141]:USER="nekoinemo"
DEBUG    2022-05-06 18:59:22,080 [command.start:141]:SUDO_ASKPASS="/home/nekoinemo/scripts/rofi_askpass.sh"
DEBUG    2022-05-06 18:59:22,080 [command.start:141]:DISPLAY=":0"
DEBUG    2022-05-06 18:59:22,081 [command.start:141]:SHLVL="1"
DEBUG    2022-05-06 18:59:22,081 [command.start:141]:QT_IM_MODULE="fcitx5"
DEBUG    2022-05-06 18:59:22,081 [command.start:141]:XDG_VTNR="7"
DEBUG    2022-05-06 18:59:22,081 [command.start:141]:XDG_SESSION_ID="2"
DEBUG    2022-05-06 18:59:22,081 [command.start:141]:XDG_RUNTIME_DIR="/run/user/1000"
DEBUG    2022-05-06 18:59:22,081 [command.start:141]:GTK3_MODULES="xapp-gtk3-module"
DEBUG    2022-05-06 18:59:22,081 [command.start:141]:PATH="/home/nekoinemo/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/nekoinemo/.cargo/bin"
DEBUG    2022-05-06 18:59:22,081 [command.start:141]:GDMSESSION="i3"
DEBUG    2022-05-06 18:59:22,081 [command.start:141]:DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus"
DEBUG    2022-05-06 18:59:22,081 [command.start:141]:MAIL="/var/spool/mail/nekoinemo"
DEBUG    2022-05-06 18:59:22,081 [command.start:141]:_="/usr/bin/lutris"
DEBUG    2022-05-06 18:59:22,081 [command.start:141]:WINDOWID="23068682"
DEBUG    2022-05-06 18:59:22,081 [command.start:141]:COLORFGBG="7;default;0"
DEBUG    2022-05-06 18:59:22,081 [command.start:141]:COLORTERM="yes"
DEBUG    2022-05-06 18:59:22,081 [command.start:141]:TERM="rxvt-unicode-256color"
DEBUG    2022-05-06 18:59:22,081 [command.start:141]:OLDPWD="/home/nekoinemo/Downloads/Jinkou Gakuen 2"
DEBUG    2022-05-06 18:59:22,081 [command.start:141]:QT_QPA_PLATFORMTHEME="qt5ct"
DEBUG    2022-05-06 18:59:22,081 [command.start:141]:PAGER="less"
DEBUG    2022-05-06 18:59:22,081 [command.start:141]:LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=00:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.avif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:*~=00;90:*#=00;90:*.bak=00;90:*.old=00;90:*.orig=00;90:*.part=00;90:*.rej=00;90:*.swp=00;90:*.tmp=00;90:*.dpkg-dist=00;90:*.dpkg-old=00;90:*.ucf-dist=00;90:*.ucf-new=00;90:*.ucf-old=00;90:*.rpmnew=00;90:*.rpmorig=00;90:*.rpmsave=00;90:"
DEBUG    2022-05-06 18:59:22,081 [command.start:141]:LESS_TERMCAP_mb=""
DEBUG    2022-05-06 18:59:22,081 [command.start:141]:LESS_TERMCAP_md=""
DEBUG    2022-05-06 18:59:22,082 [command.start:141]:LESS_TERMCAP_me=""
DEBUG    2022-05-06 18:59:22,082 [command.start:141]:LESS_TERMCAP_se=""
DEBUG    2022-05-06 18:59:22,082 [command.start:141]:LESS_TERMCAP_so=""
DEBUG    2022-05-06 18:59:22,082 [command.start:141]:LESS_TERMCAP_ue=""
DEBUG    2022-05-06 18:59:22,082 [command.start:141]:LESS_TERMCAP_us=""
DEBUG    2022-05-06 18:59:22,082 [command.start:141]:PYTHONPATH="/usr/lib/lutris:/usr/bin:/usr/lib/python310.zip:/usr/lib/python3.10:/usr/lib/python3.10/lib-dynload:/usr/lib/python3.10/site-packages"
DEBUG    2022-05-06 18:59:22,082 [command.start:141]:LUTRIS_GAME_UUID="efac8f5b-3754-436e-b596-172160635c60"
lutris-wrapper: /home/nekoinemo/.local/share/lutris/runners/wine/lutris-fshack-7.2-x86_64/bin/wine
Started initial process 3011922 from /home/nekoinemo/.local/share/lutris/runners/wine/lutris-fshack-7.2-x86_64/bin/wine /home/nekoinemo/mnt/Startup.exe
Start monitoring process.
fsync: up and running.
Initial process has exited (return code: 0)
Monitored process exited.
Exit with return code 0
DEBUG    2022-05-06 18:59:29,330 [command.on_stop:195]:Process 3011920 has terminated with code 0
```


### System Information

```shell
[System]
OS:              Arch Linux rolling n/a
Arch:            x86_64
Kernel:          5.17.5-arch1-1
Desktop:         i3
Display Server:  x11

[CPU]
Vendor:          GenuineIntel
Model:           Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Physical cores:  6
Logical cores:   12

[Memory]
RAM:             31.2 GB
Swap:            16.5 GB

[Graphics]
Vendor:          NVIDIA Corporation
OpenGL Renderer: NVIDIA GeForce GTX 1660 Ti/PCIe/SSE2
OpenGL Version:  4.6.0 NVIDIA 510.60.02
OpenGL Core:     4.6.0 NVIDIA 510.60.02
OpenGL ES:       OpenGL ES 3.2 NVIDIA 510.60.02
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:
I've been trying to reproduces this, but no joy. It seems like the 'Run EXE inside prefix' command does use the environment variables in the game configuration, for me.

Can we get more information about this? What game is it, what EXE are you running, with what custom environment variable, and how do you know it didn't get through?
(sorry, reply notification got lost in the inbox)
Here's a tiny in size patch for a game that is a good example of my issue: https://drive.google.com/file/d/12jT9oWHpI8fZzNWNvvAhc60XrDlKKPPg/view?usp=sharing
I have set up **LANG=ja_JP.UTF-8** in env, and setting this patch as main executable of the game in Lutris gives me this:
![screenshot_1654436775](https://user-images.githubusercontent.com/3595771/172053864-0313d74e-dc06-4b92-9df7-3b4dd0851f22.png)
Meanwhile using the "launch EXE in prefix" option, with env intact, results in this:
![screenshot_1654436786](https://user-images.githubusercontent.com/3595771/172053894-d2409a99-45b6-4958-8cde-7c22e983f979.png)
which is the same result as running this executable as main one of the game, without the aforementioned **LANG=ja_JP.UTF-8** env.
I have virtually the same issue (with the same environmental variable `LANG=ja_JP.UTF-8`).
I noticed that when launching Lutris from the command line via `LANG=ja_JP.UTF-8 lutris` the game works as expected.
Should I dump my system information as well?
I don't think so. What I need is a reproduction I can experience myself with my debugger attached.

But I don't own any foreign language games. Maybe there's something on Lutris.net that anyone can download and run far enough to see the bug- I've run down a few bugs that way.

But so far, I can only say "works on my machine". I need it to not work on my machine.
Have you tried to launch the patch above? Does it display correctly for you when executed through that command?
I don't think I have the game that it patches.
It's not necessary - just run the patch and see if its own UI works correctly or not
Oh, I see. It's reproing for me now. I'll look into this.

Resolving patch:
diff --git a/lutris/runners/wine.py b/lutris/runners/wine.py
--- a/lutris/runners/wine.py
+++ b/lutris/runners/wine.py
@@ -854,9 +854,7 @@ def get_env(self, os_env=False, disable_runtime=False):
         # Always false to runner.get_env, the default value
         # of os_env is inverted in the wine class,
         # the OS env is read later.
-        env = super().get_env(False, disable_runtime=disable_runtime)
-        if os_env:
-            env.update(os.environ.copy())
+        env = super().get_env(os_env, disable_runtime=disable_runtime)
         show_debug = self.runner_config.get("show_debug", "-all")
         if show_debug != "inherit":
             env["WINEDEBUG"] = show_debug


Test patch: