actions / runner-images

GitHub Actions runner images
MIT License
10.15k stars 3.06k forks source link

macOS 13 Runner cannot run applescript #7531

Closed wkiefer closed 1 year ago

wkiefer commented 1 year ago

Description

This seems like the same issue as https://github.com/actions/runner-images/issues/553 but for the new macOS 13 image.

Running any /usr/bin/osascript commands yields:

execution error: Finder got an error: AppleEvent timed out. (-1712)

(I know this is a beta runner image but wanted to flag early)

Platforms affected

Runner images affected

Image version and build link

Image: macos-13 Version: 20230426.3 Included Software: https://github.com/actions/runner-images/blob/macOS-13/20230426.3/images/macos/macos-13-Readme.md Image Release: https://github.com/actions/runner-images/releases/tag/macOS-13%2F20230426.3

Is it regression?

https://github.com/actions/runner-images/releases/tag/macOS-12%2F20230425.1

Expected behavior

run /usr/bin/osascript <applescript-file> works

Actual behavior

Running any /usr/bin/osascript commands yields:

execution error: Finder got an error: AppleEvent timed out. (-1712)

Repro steps

Attempt to run an applescript commend (examples in https://github.com/actions/runner-images/issues/553 )

Alexey-Ayupov commented 1 year ago

Hello @wkiefer, we will take a look.

battlebottle commented 1 year ago

I'm running into this issue also.

I might add though that the xamarin/xamarin-macios macos dotnet workload dropped support for Mac OS 12.X as of today, as such my Mac OS builds are failing on the macos-12 runner image. It also happens that the dotnet workload installer does not provide a public mechanism for installing a specific version of a workload (there is an undocumented method seemingly, but I unable to get that to work on the macos-12 image). So I have no way of simply rolling back.

I tried the macos-13 image of course, but I'm running into the apple script timeout issue when running create-dmg as part of my build process.

I know the macos-13 runner is still in beta, but but you might consider prioritizing issues like this all the same as I'm hardly the only person running into this problem today.

sergei-pyshnoi commented 1 year ago

Hello @battlebottle. We currently working on it. We post information here as fast as we got any results.

PatTheMav commented 1 year ago

@wkiefer Thanks for reporting this - any project that uses the common AppleScript-based approach to create DMGs for distribution on CI will be blocked by this.

The macOS-13 runners are in beta and GitHub explicitly mentions that they're not feature complete, so here's hoping that this will be fixed for their final release.

grzegorzkrukowski commented 1 year ago

I can only confirm we are having the same problem - using https://github.com/create-dmg/create-dmg to create our DMG and it fails on the same step with this exact error.

ayoy commented 1 year ago

For anyone blocked by it and looking for a temporary solution – here’s a workaround that I have in place, which does the job for me:

grzegorzkrukowski commented 1 year ago

For anyone blocked by it and looking for a temporary solution – here’s a workaround that I have in place, which does the job for me:

  • build the app on macos-13 runner and upload the app as artifact
  • launch a separate job on macos-12 runner that depends on the job above – it downloads the artifact and creates DMG.

I thought about it, but for private repositories it will use the storage limit - for my application and amount of builds we do, it will drain it pretty quickly and then you have to pay for it.

ayoy commented 1 year ago

@grzegorzkrukowski if you don’t need the app artifact, you can set it to expire after 1 day. This way it wouldn’t add too much to storage limit.

grzegorzkrukowski commented 1 year ago

@Alexey-Ayupov is there any ETA on when this will be fixed ?

everuribe commented 1 year ago

any luck with this issue?

sergei-pyshnoi commented 1 year ago

We currently in investigation process. We will post updates as soon as we got any result.

sergei-pyshnoi commented 1 year ago

@wkiefer We found possible problem in system permission. As workaround, you can modify it by adding necessary to TCC.db by adding this commands before applescript execution:

sudo sqlite3 $HOME/Library/Application\ Support/com.apple.TCC/TCC.db "INSERT OR REPLACE INTO access VALUES('kTCCServiceAppleEvents','/usr/local/opt/runner/provisioner/provisioner',1,2,3,1,NULL,NULL,0,'com.apple.finder',X'fade0c000000002c00000001000000060000000200000010636f6d2e6170706c652e66696e64657200000003',NULL,1592919552);"
sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "INSERT OR REPLACE INTO access VALUES('kTCCServiceAppleEvents','/usr/local/opt/runner/provisioner/provisioner',1,2,3,1,NULL,NULL,0,'com.apple.finder',X'fade0c000000002c00000001000000060000000200000010636f6d2e6170706c652e66696e64657200000003',NULL,1592919552);"

In my test workflow osascript -e 'tell application "Finder" to close windows'and osascript -e 'tell application "Finder" to open POSIX file "/Users/runner/"' finished without timeout error.

VitoVan commented 1 year ago

@wkiefer We found possible problem in system permission. As workaround, you can modify it by adding necessary to TCC.db by adding this commands before applescript execution:

sudo sqlite3 $HOME/Library/Application\ Support/com.apple.TCC/TCC.db "INSERT OR REPLACE INTO access VALUES('kTCCServiceAppleEvents','/usr/local/opt/runner/provisioner/provisioner',1,2,3,1,NULL,NULL,0,'com.apple.finder',X'fade0c000000002c00000001000000060000000200000010636f6d2e6170706c652e66696e64657200000003',NULL,1592919552);"
sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "INSERT OR REPLACE INTO access VALUES('kTCCServiceAppleEvents','/usr/local/opt/runner/provisioner/provisioner',1,2,3,1,NULL,NULL,0,'com.apple.finder',X'fade0c000000002c00000001000000060000000200000010636f6d2e6170706c652e66696e64657200000003',NULL,1592919552);"

In my test workflow osascript -e 'tell application "Finder" to close windows'and osascript -e 'tell application "Finder" to open POSIX file "/Users/runner/"' finished without timeout error.

I confirm this worked in my workflow.

Thank you @sergei-pyshnoi

wkiefer commented 1 year ago

Thank you @sergei-pyshnoi -- our team will try this ASAP

MShekow commented 1 year ago

I too have the same error, see the build https://github.com/focus-time/focus-time-app/actions/runs/5410089800/jobs/9831069845

Essentially, if you look at the code, you see that I'm doing this:

open resources/focus-time-app.shortcut  # open Shortcuts app with a specific, prepared shortcut
sleep 15
osascript .github/macos-hacks/install-shortcut-unattended.scpt

The script itself is something as simple as:

tell application "System Events" to tell process "Shortcuts"
    set frontmost to true
    delay 1

    tell window 1
        UI elements
    end tell

end tell
sergei-pyshnoi commented 1 year ago

I too have the same error, see the build https://github.com/focus-time/focus-time-app/actions/runs/5410089800/jobs/9831069845

Essentially, if you look at the code, you see that I'm doing this:

open resources/focus-time-app.shortcut  # open Shortcuts app with a specific, prepared shortcut
sleep 15
osascript .github/macos-hacks/install-shortcut-unattended.scpt

The script itself is something as simple as:

tell application "System Events" to tell process "Shortcuts"
    set frontmost to true
    delay 1

    tell window 1
        UI elements
    end tell

end tell

In your case your need to add another permission. I tried add it in fork from youre workflow, and look like it work.

sudo sqlite3 $HOME/Library/Application\ Support/com.apple.TCC/TCC.db "INSERT OR REPLACE INTO access VALUES('kTCCServiceAppleEvents','/usr/local/opt/runner/provisioner/provisioner',1,2,3,1,NULL,NULL,0,'com.apple.systemevents',X'fade0c000000003400000001000000060000000200000016636f6d2e6170706c652e73797374656d6576656e7473000000000003',NULL,1592919552);"
sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,NULL,1592919552);"

We plan to add this permissions to image in near future, before it, please use provided workaround.

MShekow commented 1 year ago

In your case your need to add another permission. I tried add it in fork from youre workflow, and look like it work.

sudo sqlite3 $HOME/Library/Application\ Support/com.apple.TCC/TCC.db "INSERT OR REPLACE INTO access VALUES('kTCCServiceAppleEvents','/usr/local/opt/runner/provisioner/provisioner',1,2,3,1,NULL,NULL,0,'com.apple.systemevents',X'fade0c000000003400000001000000060000000200000016636f6d2e6170706c652e73797374656d6576656e7473000000000003',NULL,1592919552);"
sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,NULL,1592919552);"

We plan to add this permissions to image in near future, before it, please use provided workaround.

I can confirm that this works, thank you.

sergei-pyshnoi commented 1 year ago

Fix deployed

wkiefer commented 1 year ago

Hi @sergei-pyshnoi -- this has been fixed for the last ~2 months (thank you!). However we just started seeing it again yesterday. Is it possible that the recent upgrade of Xcode by @erik-bershel could have caused this to regress in any way?

erik-bershel commented 1 year ago

@wkiefer Apple security updates more likely. We'll see.

wkiefer commented 1 year ago

@wkiefer Apple security updates more likely. We'll see.

Thank you so much @erik-bershel !

FYI: It seems the suggested workaround mentioned earlier in the thread does not work (I just tested and still hit timeouts).

mikhailkoliada commented 1 year ago

looks like it is working again!