Whisky-App / Whisky

A modern Wine wrapper for macOS built with SwiftUI
https://getwhisky.app
GNU General Public License v3.0
11.23k stars 238 forks source link

[Bug]: winetricks don't work with non-POSIX login shell #470

Open phistep opened 9 months ago

phistep commented 9 months ago

Description

I use https://xon.sh/ as my login shell and it is not POSIX compatible. In particular, environment variables and string quoting work differently from regular shells.

Last login: Wed Sep 27 00:26:57 on ttys007
PATH="/Users/phistep/Library/Application Support/com.isaacmarovitz.Whisky/Libraries/Wine/bin:$PATH" WINE=wine64 WINEPREFIX="/Users/phistep/Library/Containers/com.isaacmarovitz.Whisky/Bottles/0C9A8D20-A05D-4567-A397-C8B0CA299993" "/Users/phistep/Library/Application Support/com.isaacmarovitz.Whisky/Libraries/winetricks" corefonts

~ via 🐍 v3.11.5 
>>> PATH="/Users/phistep/Library/Application Support/com.isaacmarovitz.Whisky/Li
braries/Wine/bin:$PATH" WINE=wine64 WINEPREFIX="/Users/phistep/Library/Container
s/com.isaacmarovitz.Whisky/Bottles/0C9A8D20-A05D-4567-A397-C8B0CA299993" "/Users
/phistep/Library/Application Support/com.isaacmarovitz.Whisky/Libraries/winetric
ks" corefonts
xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True
xonsh: subprocess mode: command not found: PATH="/Users/phistep/Library/Application Support/com.isaacmarovitz.Whisky/Libraries/Wine/bin:/Users/phistep/.cargo/bin:/Users/phistep/.local/bin:/usr/local/texlive/2021/bin/universal-darwin/:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/bin:/bin"

when I change my login shell to /bin/zsh, everything works as expected

chpass -s /bin/zsh $USER

Steps to reproduce

  1. Install xonsh.
    brew install xonsh
    # or pip3 install xonsh
  2. Set it as login shell
    chpass -s /opt/homebrew/bin/xonsh $USER
  3. Launch Whisky
  4. Select a bottle in the side bar
  5. Press the Winetricks... button at the bottom of the screen
  6. Run a winetrick, e.g.g corefonts image
  7. Press Run...

Expected behaviour

The winetricks command is executed in a POSIX compatible system shell regardless of the users' login shell. The command executes without error.

Logs

no Wine process launched as command could not be executed

What version of Whisky are you using?

2.0.1

What version of macOS are you using?

Sonoma (macOS 14)

Issue Language

GabCoolDude commented 9 months ago

Use the default terminal.

phistep commented 9 months ago

It does open the default terminal /Applications/Utilities/Terminal.app (while I personally use iTerm2), but the terminal emulator does not make any difference, they're all going to respect the login shell. I don't want to change my login shell just for Whisky.

My guess would be that https://github.com/Whisky-App/Whisky/blob/ddabb28208f401a5d659d08485078c37882c28a0/Whisky/Utils/Winetricks.swift#L29C7-L29C7

let winetricksCmd = #"PATH=\"\#(Wine.binFolder.path):$PATH\" WINE=wine64 WINEPREFIX=\"\#(bottle.url.path)\" \"\#(winetricksURL.path(percentEncoded: false))\" \#(command)"#

could be changed to

let winetricksCmd = #"/bin/sh -c "PATH=\"\#(Wine.binFolder.path):$PATH\"; WINE=wine64; WINEPREFIX=\"\#(bottle.url.path)\"; \"\#(winetricksURL.path(percentEncoded: false))\"; \#(command)"#

(using /bin/sh as the shell to execute the command using -c, then define the shell variables not as preamble to the shell command but as separate statements in the "script" parameter, thus one has to terminate each variable definition statement using ;.