mobile-dev-inc / maestro

Painless Mobile UI Automation
https://maestro.mobile.dev/
Apache License 2.0
5.76k stars 266 forks source link

Homebrew installation fails on M1 machines #402

Closed dmitry-zaitsev closed 1 year ago

dmitry-zaitsev commented 1 year ago

Something related to JDK 8 change:

% brew install maestro
openjdk@8: The x86_64 architecture is required for this software.
Error: maestro: An unsatisfied requirement failed this build.
ubiratansoares commented 1 year ago

I tried to install maestro via brew today and I ran in the same issue. I did a dive into it, hope my insights are useful :)

First things first : it seems the official openjdk@8 formula on homebrew-core does not support Apple Silicon targets. A comparison can be made against openjdk@11, where we have aarch64 as valid targets.

Also, accordingly the current documentation for the brew packager, jreleaser adds openjdk@8 as a dependency in the formulae unless instructed to do differently. This is the reason behind the reported error.

That being said, I see some solutions here

(a) we could tweak the current jreleaser configuration so it skips any dependency on openjdk at all

    distributions {
        maestro {
            artifact {
                path = 'build/distributions/maestro.zip'
            }
            brew {
                extraProperties.put('skipJava', 'true')

            // ....
            } 
    }

or

(b) we could force openjdk@11 (or newer) as a dependency of the Formula generated by jreleaser

    distributions {
        maestro {
            artifact {
                path = 'build/distributions/maestro.zip'
            }
            brew {
                extraProperties.put('skipJava', 'true') // You still need this as it seems
                active = 'RELEASE'
                formulaName = 'Maestro'

                repoTap {
                    owner = 'mobile-dev-inc'
                    name = 'homebrew-tap'
                }

                dependencies {
                    dependency(':openjdk@11')
                }
            } 
    }

In both cases the generated Ruby formula can be checked by running

$>./gradlew clean maestro-cli:jreleaserPackage

and following contents at maestro-cli/build/jreleaser/package

Personal opinion here : I'd stick with option (a) because I don't like when some brew formula installs an openjdk distribution as a dependency (I manage my Zulu JDKs already with this brew tap). Also, this is the same behaviour provided by maestro's curl | bash installer.

Maybe there are strong reasons to have maestro running on top of openjdk@8; if that is the case, then you could eventually provide a custom jreleaser template for the target formula, detecting aarch64 and using some of the homebrew utility functions to warn the user that a proper standalone JDK8 installation is required over Apple Silicon machine.

Happy to raise a PR eventually fixing the issue 🙂

dmitry-zaitsev commented 1 year ago

@ubiratansoares I agree with option (a) - a PR would be very much welcome!

github-actions[bot] commented 3 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar problem, please file a new issue. Make sure to follow the template and provide all the information necessary to reproduce the issue. Thank you for helping keep us our issue tracker clean!