Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CircleCI] Finder got an error: AppleEvent timed out. (-1712) #145

Closed
2 of 5 tasks
ogerardin opened this issue Feb 14, 2022 · 6 comments
Closed
2 of 5 tasks

[CircleCI] Finder got an error: AppleEvent timed out. (-1712) #145

ogerardin opened this issue Feb 14, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@ogerardin
Copy link
Contributor

I'm submitting a…

  • bug report
  • feature request
  • other

Short description of the issue/suggestion:
When running on CircleCI with macOS executor, DMG image generation fails with message "bundle format unrecognized, invalid, or unsuitable"

Steps to reproduce the issue/enhancement:

  1. Configure the plugin to generate a DMG for mac
  2. Configure CircleCI to build with macOS executor
  3. Run pipeline

What is the expected behavior?
DMG file is generated

What is the current behavior?
Failure during DMG generation with error described above

Do you have outputs, screenshots, demos or samples which demonstrate the problem or enhancement?
See example build: https://app.circleci.com/pipelines/github/ogerardin/xpman/24/workflows/6dca15e1-1d24-47ca-9c06-29caa2c8ba9d/jobs/58?invite=true#step-103-2530

Please tell us about your environment:

  • JavaPackager version: 1.6.3
  • OS version: 12.2
  • JDK version: 11.0.11
  • Build tool:
    • Maven
    • Gradle

Other information (e.g. related issues, suggestions how to fix, links for us to have context)
I've tested with XCode images 13.2.1 and 13.3.0.
CircleCI macOS images: https://circleci.com/docs/2.0/testing-ios/#supported-xcode-versions
DMG generation works fine on my own Mac (macOS 12.2.1).

@fvarrui
Copy link
Owner

fvarrui commented Feb 14, 2022

Hi @ogerardin!
I've seen that you are bundling a JDK with your app. Please, try to remove jrePath property in order to generate a customized JRE.

@fvarrui
Copy link
Owner

fvarrui commented Feb 14, 2022

It fails when codesigning the app 🤷‍♂️

@ogerardin
Copy link
Contributor Author

Hi @ogerardin! I've seen that you are bundling a JDK with your app. Please, try to remove jrePath property in order to generate a customized JRE.

I did what you suggested (i'm moving this project from Java 8...) now it seems to go further :) But then I get an error "Finder got an error: AppleEvent timed out. (-1712)" when executing AppleScript https://app.circleci.com/pipelines/github/ogerardin/xpman/36/workflows/8c7812ef-1ffa-4cb7-bf39-2c74eacbdf98/jobs/87?invite=true#step-103-2549

I've noticed that the CircleCI macOS executor isn't very fast, maybe you could increase the timeout ? It seems to be 2 minutes by default, and that might not be enough for this operation.

(Also, even though there is an error, the build is considered successful...)

@fvarrui
Copy link
Owner

fvarrui commented Feb 15, 2022

Wow!!! It was hard to find a solution for this problem, but I finally managed to reproduce and fix it. After trying several options, I finally found this.

As far as I can understand, osascript (AppleScript executor) asks for permissions (user interaction), and of course, since it's running on Circle CI (non-interactive), after a waiting time the error occurred (Finder got an error: AppleEvent timed out. (-1712)) as it never gets a response.

Run next commands before packaging fix the problem:

epochdate=$(($(date +'%s * 1000 + %-N / 1000000')))
tcc_service_appleevents="replace into access (service,client,client_type,auth_value,auth_reason,auth_version,indirect_object_identifier_type,indirect_object_identifier,flags,last_modified) values (\"kTCCServiceAppleEvents\",\"/usr/sbin/sshd\",1,2,4,1,0,\"com.apple.finder\",0,$epochdate);"
sudo sqlite3 "/Users/distiller/Library/Application Support/com.apple.TCC/TCC.db" "$tcc_service_appleevents"

It gives to "sshd" (SSH server used by CircleCI to run commands on the VM/container) permissions on "Finder".

And your Circle CI config file has to look like this:

  build-mac:
    macos:
      xcode: 13.3.0
    steps:
      - run:
          name: Fix Finder got an error - AppleEvent timed out. (-1712)
          command: |
            epochdate=$(($(date +'%s * 1000 + %-N / 1000000')))
            tcc_service_appleevents="replace into access (service,client,client_type,auth_value,auth_reason,auth_version,indirect_object_identifier_type,indirect_object_identifier,flags,last_modified) values (\"kTCCServiceAppleEvents\",\"/usr/sbin/sshd\",1,2,4,1,0,\"com.apple.finder\",0,$epochdate);"
            sudo sqlite3 "/Users/distiller/Library/Application Support/com.apple.TCC/TCC.db" "$tcc_service_appleevents"
      - run:
          name: Install Maven
          command: brew install maven
      - checkout
      - run:
          name: Build
          command: |
            /usr/libexec/java_home -V
            export JAVA_HOME=`/usr/libexec/java_home -v 11`
            mvn -v
            mvn -B -DskipTests clean package

@fvarrui
Copy link
Owner

fvarrui commented Feb 15, 2022

I forgot it! ... the execution of the AppleScript by JavaPackager is only for customizing the generated DMG, hence the process continues even if the execution of this script fails.

I hope it helps!

@fvarrui fvarrui changed the title [CircleCI] DMG image generation fails with "bundle format unrecognized, invalid, or unsuitable" [CircleCI] Finder got an error: AppleEvent timed out. (-1712) Feb 15, 2022
@fvarrui fvarrui added the bug Something isn't working label Feb 15, 2022
@ogerardin
Copy link
Contributor Author

Thanks for putting in all the effort! It does solve the problem. It was not an actual timeout problem or a bug in the plugin :)

Maybe you should put this in the Mac section of the doc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants