Gitk doesn't work on macOS Mojave

4 messages, 2 authors, 2018-07-19 · open the first message on its own page

Gitk doesn't work on macOS Mojave

From: Evgeny Cherpak <hidden>
Date: 2018-07-19 18:48:41

Hi

You have probably heard this by now already, but gitk doesn’t work on macOS 10.14 - because it uses Apple Events,
And apps on 10.14 require user to give them permissions to control other apps with Apple Events.

Here is what I get when I try running it on my machine with beta 4 installed:

Error in startup script: 58:102: execution error: Not authorized to send Apple events to System Events. (-1743)
    while executing
"exec osascript -e [format {
        tell application "System Events"
            set frontmost of processes whose unix id is %d to true
        end te..."
    invoked from within
"if {[tk windowingsystem] eq "aqua"} {
    exec osascript -e [format {
        tell application "System Events"
            set frontmost of processes ..."
    (file "/usr/local/bin/gitk" line 12212)

And Apple doesn’t allow to add apps to “Automation” :( 

Best regards.
And thanks for git :) 

Re: Gitk doesn't work on macOS Mojave

From: Eric Sunshine <hidden>
Date: 2018-07-19 19:13:12

On Thu, Jul 19, 2018 at 2:48 PM Evgeny Cherpak [off-list ref] wrote:
You have probably heard this by now already, but gitk doesn’t work on macOS 10.14 - because it uses Apple Events,
And apps on 10.14 require user to give them permissions to control other apps with Apple Events.
This hasn't been reported, so thanks for bringing it up.
Here is what I get when I try running it on my machine with beta 4 installed:

Error in startup script: 58:102: execution error: Not authorized to send Apple events to System Events. (-1743)
    while executing
"exec osascript -e [format {
        tell application "System Events"
            set frontmost of processes whose unix id is %d to true
        end te..."
Fortunately, this feature is merely a convenience, not otherwise
critical to gitk functioning. It would be ideal if someone running
Mojave could devise up a patch to work around the problem (either by
skipping this code on Mojave or discovering a different way to bring
the application to the foreground). An alternative would be to revert
76bf6ff93e (gitk: On OSX, bring the gitk window to front, 2013-04-24),
which introduced this code.

(Note, however, that the gitk project is dormant, so it's not clear if
such a patch will be picked up.)

Re: Gitk doesn't work on macOS Mojave

From: Evgeny Cherpak <hidden>
Date: 2018-07-19 21:11:18

It seems this code placed at the end of the file, after getcommits() does the trick:

if {[tk windowingsystem] eq "aqua"} { 
	set openscript [format { 
		open -a \"$(ps -p %d -o comm=)\"
	} [pid] ]
    exec osascript -e [format {
		do shell script "%s"
    } "$openscript” ]
}

On 19 Jul 2018, at 22:12, Eric Sunshine [off-list ref] wrote:

On Thu, Jul 19, 2018 at 2:48 PM Evgeny Cherpak [off-list ref] wrote:
quoted
You have probably heard this by now already, but gitk doesn’t work on macOS 10.14 - because it uses Apple Events,
And apps on 10.14 require user to give them permissions to control other apps with Apple Events.
This hasn't been reported, so thanks for bringing it up.
quoted
Here is what I get when I try running it on my machine with beta 4 installed:

Error in startup script: 58:102: execution error: Not authorized to send Apple events to System Events. (-1743)
   while executing
"exec osascript -e [format {
       tell application "System Events"
           set frontmost of processes whose unix id is %d to true
       end te..."
Fortunately, this feature is merely a convenience, not otherwise
critical to gitk functioning. It would be ideal if someone running
Mojave could devise up a patch to work around the problem (either by
skipping this code on Mojave or discovering a different way to bring
the application to the foreground). An alternative would be to revert
76bf6ff93e (gitk: On OSX, bring the gitk window to front, 2013-04-24),
which introduced this code.

(Note, however, that the gitk project is dormant, so it's not clear if
such a patch will be picked up.)

Re: Gitk doesn't work on macOS Mojave

From: Eric Sunshine <hidden>
Date: 2018-07-19 21:49:31

[please reply inline rather than top-posting]

On Thu, Jul 19, 2018 at 5:11 PM Evgeny Cherpak [off-list ref] wrote:
It seems this code placed at the end of the file, after getcommits() does the trick:

if {[tk windowingsystem] eq "aqua"} {
        set openscript [format {
                open -a \"$(ps -p %d -o comm=)\"
        } [pid] ]
    exec osascript -e [format {
                do shell script "%s"
    } "$openscript” ]
}
Interesting idea. A shortcoming of this approach is that it's
non-deterministic. It will bring _any_ running gitk to the foreground,
rather than the one mentioned by PID, which would be a potentially
confusing regression. Such confusion _might_ be worse than simply not
foregrounding the application at all (though that's a matter of
opinion). Unfortunately, the 'open' command doesn't let you do so by
PID, and Googling shows only answers which predate Mojave (that is,
they all suggest Apple Events).

To avoid such a regression on older MacOS's, it would be nice to
retain the Apple Events code, but that would mean gitk would need to
do a version check or something to avoid executing the Apple Events
code on Mojave.

By the way, the same problem presumably afflicts "git gui", which has
identical code in it for foregrounding the application. Does that
match with your experience?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help