Opened 5 months ago

Last modified 13 days ago

#64249 reopened defect

git gui opens a window with no usable content

Reported by: akimd (Akim Demaille) Owned by: ci42
Priority: Normal Milestone:
Component: ports Version: 2.7.1
Keywords: monterey Cc: herbygillot (Herby Gillot), chrstphrchvz (Christopher Chavez), zman0900 (Dan Ziemba), telotortium (Robert Irelan)
Port: git

Description

On 12.1, git gui opens a window with four different panes (the list of files, the diffs etc.) but all of them are black. It's not usable at all. I'm in dark mode.

Attachments (1)

git gui.png (232.2 KB) - added by akimd (Akim Demaille) 5 months ago.
Screenshot

Download all attachments as: .zip

Change History (15)

Changed 5 months ago by akimd (Akim Demaille)

Attachment: git gui.png added

Screenshot

comment:1 Changed 5 months ago by ryandesign (Ryan Schmidt)

Cc: herbygillot added
Keywords: monterey added
Owner: set to ci42
Status: newassigned

comment:2 Changed 5 months ago by chrstphrchvz (Christopher Chavez)

git gui is using Tcl/Tk Aqua 8.5.9 included in macOS, which is very old and appears to be unusable on macOS 12. Since macOS 10.15, the system Tcl/Tk has been deprecated and is likely to be removed in future macOS (as warned on the command line).

If git gui is using wish from PATH, then installing MacPorts’ tk (either the +quartz or +x11 variant is fine) may work around this issue.

If git gui and gitk should always be using MacPorts’ Tcl/Tk, it may be desirable to separate them from the git port, so that git itself isn’t dependent on Tcl/Tk ports.

Last edited 5 months ago by chrstphrchvz (Christopher Chavez) (previous) (diff)

comment:3 Changed 5 months ago by chrstphrchvz (Christopher Chavez)

Cc: chrstphrchvz added

comment:4 Changed 5 months ago by akimd (Akim Demaille)

Hi Christopher, git gui is hard-coded to use its own Wish:

$ cat /opt/local/libexec/git-core/git-gui
#!/bin/sh
if test "z$*" = zversion ||
   test "z$*" = z--version
then
        echo 'git-gui version 0.21.0.99.gdf4f9e'
else
        libdir="${GIT_GUI_LIB_DIR:-/opt/local/share/git-gui/lib}"
        exec "$libdir/Git Gui.app/Contents/MacOS/Wish" "$0" "$@"
fi

But this Wish (which is a universal binary) appears to be doing something special. Just replacing it with macport's does not work. It execs

exec '/opt/local/share/git-gui/lib/Git Gui.app/Contents/MacOS/Wish' /opt/local/libexec/git-core/git-gui

Yes, it is passing the above shell script to that Wish, which appears to handle it in a special way. The regular wish won't grok it.

$ /opt/local/bin/wish /opt/local/libexec/git-core/git-gui
Error in startup script: invalid bareword "test"
in expression "test";
should be "$test" or "{test}" or "test(...)" or ...
    (parsing expression "test")
    invoked from within
"if test "z$*" = zversion ||"
    (file "/opt/local/libexec/git-core/git-gui" line 2)

I have no idea what needs to be passed to it. My best try won't work.

$ /opt/local/bin/wish /opt/local/share/git-gui/lib/git-gui.tcl -- browser
usage: /opt/local/share/git-gui/lib/git-gui.tcl [{blame|browser|citool}]

I don't understand what it wants and how my command line is incorrect.

comment:5 Changed 5 months ago by chrstphrchvz (Christopher Chavez)

Did you try $ /opt/local/bin/wish /opt/local/share/git-gui/lib/git-gui.tcl browser (no --)?

Git Gui.app/Contents/MacOS/Wish appears to be copied from /System/Library/Frameworks/Tk.framework/Resources/Wish.app/Contents/MacOS/Wish during build.

If building Git Gui.app is desirable, I’m not aware whether it requires Tk to be built as a framework, which MacPorts Tk currently does not do. (Homebrew does not build Tk as a framework either, and they opted to not provide Git Gui.app: https://github.com/Homebrew/homebrew-core/commit/dfa3ccf1e7d3)

comment:6 Changed 5 months ago by akimd (Akim Demaille)

Yes, I had tried that, to no avail.

It turns out that this git-gui.tcl script makes stupid and useless error messages. In most situations of errors it just dumps this stupid usage message instead of forging a genuine error message that tells what it's unhappy about. And once you hacked your way into the script and add details, you find out that this script looks at its name (argv[0]) to decide what to do. And it is taught to recognize git-gui, not git-gui.tcl...

So I have ln -s git-gui.tcl git-gui and now /opt/local/bin/wish /opt/local/share/git-gui/lib/git-gui works properly (no argument such as browser is needed).

I don't understand how

$ cat /opt/local/libexec/git-core/git-gui
#!/bin/sh
if test "z$*" = zversion ||
   test "z$*" = z--version
then
        echo 'git-gui version 0.21.0.99.gdf4f9e'
else
        libdir="${GIT_GUI_LIB_DIR:-/opt/local/share/git-gui/lib}"
        exec "$libdir/Git Gui.app/Contents/MacOS/Wish" "$0" "$@"
fi

works exactly, but there appears to be some magic in $libdir/Git Gui.app/Contents/MacOS/Wish on the way it groks $0. If you do the obvious thing (replace that Wish with /opt/local/bin/wish) it fails, and the error message shows that tcl was really try to read $0, i.e., a shell script, and failed:

$ git gui
Error in startup script: invalid bareword "test"
in expression "test";
should be "$test" or "{test}" or "test(...)" or ...
    (parsing expression "test")
    invoked from within
"if test "z$*" = zversion ||"
    (file "/opt/local/libexec/git-core/git-gui" line 2)

So we still need to find a way for /opt/local/libexec/git-core/git-gui to work out of the box. The obvious

$ cat /opt/local/libexec/git-core/git-gui
#!/bin/sh
if test "z$*" = zversion ||
   test "z$*" = z--version
then
        echo 'git-gui version 0.21.0.99.gdf4f9e'
else
        libdir="${GIT_GUI_LIB_DIR:-/opt/local/share/git-gui/lib}"
        exec "/opt/local/bin/wish" "$libdir/git-gui" "$@"
fi

works.

Last edited 4 months ago by ryandesign (Ryan Schmidt) (previous) (diff)

comment:7 Changed 8 weeks ago by zman0900 (Dan Ziemba)

Cc: zman0900 added

comment:8 Changed 6 weeks ago by chrstphrchvz (Christopher Chavez)

I believe #64925 is a duplicate of this

comment:9 Changed 6 weeks ago by gma-uw (gma1)

Thanks for the redirect to this.

FYI, I made the suggested symlink on my machine as follows

ln -s /opt/local/share/git-gui/lib/git-gui.tcl /opt/local/share/git-gui/lib/git-gui

Then I get this strange behavior:

/opt/local/bin/wish /opt/local/share/git-gui/lib/git-gui.tcl FAILS

/opt/local/bin/wish /opt/local/share/git-gui/lib/git-gui WORKS

At least something works, but I have no idea why.

Last edited 5 weeks ago by ryandesign (Ryan Schmidt) (previous) (diff)

comment:10 Changed 5 weeks ago by mohd-akram (Mohamed Akram)

Resolution: fixed
Status: assignedclosed

In 4bfc47deb6919ff5a90fdf8c6b90317586324322/macports-ports (master):

git: do not bundle tk for gui

Fixes: #62036
Fixes: #64249

comment:11 Changed 4 weeks ago by zman0900 (Dan Ziemba)

With git 2.35.3_0 installed on MacOS 12.3.1 x86_64, running either gitk or git gui still results in an unusable, mostly black window.

comment:12 Changed 4 weeks ago by zman0900 (Dan Ziemba)

Resolution: fixed
Status: closedreopened

Both still output deprecation warning about system tk. gitk also shows this error after closing the window:

Error in startup script: can't invoke "tk" command:  application has been destroyed
    while executing
"tk windowingsystem"
    invoked from within
"if {[tk windowingsystem] eq "win32"} {
    focus -force .
}"
    (file "/opt/local/bin/gitk" line 12697)

comment:13 Changed 13 days ago by telotortium (Robert Irelan)

Cc: telotortium added

comment:14 Changed 13 days ago by telotortium (Robert Irelan)

On my computer (macOS Monterey 12.3.1 M1), the issue is fixed for me by installed tk with the quartz variant - the x11 variant doesn't work for me. I have XQuartz installed (from http://xquartz.org I believe).

Note: See TracTickets for help on using tickets.