google / protobuf-gradle-plugin

Protobuf Plugin for Gradle
Other
1.77k stars 273 forks source link

"Could not find protoc-osx-aarch_64.exe" on Apple M2 #680

Closed emeraldhieu closed 1 year ago

emeraldhieu commented 1 year ago

Hello, I'm using "protobuf-gradle-plugin/examples/exampleProject" at tag v0.9.2.

I get this error.

abc@xyz exampleProject % ./gradlew build 

Welcome to Gradle 5.6.4!

Here are the highlights of this release:
 - Incremental Groovy compilation
 - Groovy compile avoidance
 - Test fixtures for Java projects
 - Manage plugin versions via settings script

For more details see https://docs.gradle.org/5.6.4/release-notes.html

> Task :extractIncludeProto
> Task :extractProto
> Task :generateProto FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':generateProto'.
> Could not resolve all files for configuration ':protobufToolsLocator_protoc'.
   > Could not find protoc-osx-aarch_64.exe (com.google.protobuf:protoc:3.6.1).
     Searched in the following locations:
         https://repo.maven.apache.org/maven2/com/google/protobuf/protoc/3.6.1/protoc-3.6.1-osx-aarch_64.exe

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 726ms
3 actionable tasks: 3 executed

Apple M2 MacOS Ventura

Any idea how to fix it?

ejona86 commented 1 year ago

Use a newer version of protoc. This isn't a problem with the plugin; the older protobuf versions didn't support aarch64 on Mac.

iTiPo commented 10 months ago

@ejona86 hi!

I updated protoc to the newest version but still get a similar error. What do I do wrong?

Here is my setup:

import com.google.protobuf.gradle.id

val grpcKotlinVersion = "1.4.1"
val grpcVersion = "1.61.0"
val protobufVersion = "3.25.2"

plugins {
    kotlin("jvm")
    id("com.google.protobuf")
}

repositories {
    mavenCentral()
}

dependencies {
    api("io.grpc:grpc-kotlin-stub:$grpcKotlinVersion")
    api("io.grpc:grpc-protobuf:$grpcVersion")
    api("io.grpc:grpc-netty:$grpcVersion")
    api("com.google.protobuf:protobuf-kotlin:$protobufVersion")
}

kotlin {
    jvmToolchain(17)
}

protobuf {
    protoc {
        artifact = "com.google.protobuf:protoc:$protobufVersion"
    }
    plugins {
        id("grpc") {
            artifact = "io.grpc:protoc-gen-grpc-java:$grpcVersion"
        }
        id("grpckt") {
            artifact = "io.grpc:protoc-gen-grpc-kotlin:$grpcKotlinVersion:jdk8@jar"
        }
    }
    generateProtoTasks {
        all().forEach {
            it.plugins {
                id("grpc")
                id("grpckt")
            }
            it.builtins {
                id("kotlin")
            }
        }
    }
}

The error:

Execution failed for task ':my-service:generateProto'.
> protoc: stdout: . stderr: /Users/my-name/.gradle/caches/modules-2/files-2.1/io.grpc/protoc-gen-grpc-java/1.61.0/2dfdef88b003b4ad87072a2ce214579fd670bd63/protoc-gen-grpc-java-1.61.0-osx-aarch_64.exe: program not found or is not executable
  Please specify a program using absolute path or make sure the program is available in your PATH system variable
  --grpc_out: protoc-gen-grpc: Plugin failed with status code 1.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.2.1/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 349ms
13 actionable tasks: 1 executed, 12 up-to-date
iTiPo commented 10 months ago

I found few related issues and just installed Rosetta 2 by the following command in Terminal:

softwareupdate --install-rosetta --agree-to-license