google / protobuf-gradle-plugin

Protobuf Plugin for Gradle
Other
1.76k stars 274 forks source link

Codegen plugins from system search path no longer work #699

Closed ateirney closed 1 year ago

ateirney commented 1 year ago

After upgrading from 0.8.19 to 0.9.X I was no longer able to use codegen plugins that should be located using the system path.

The error that was given was the following.

ExecutableLocator with name 'bq-schema' not found.

YifeiZhuang commented 1 year ago

The system search path is not working for me either. I got this error:

 Caused by: org.gradle.api.GradleException: protoc: stdout: . stderr: protoc-gen-grpc: program not found or is not executable
    --grpc_out: protoc-gen-grpc: Plugin failed with status code 1.

looking at the command generated it seems not correct: --plugin=protoc-gen-grpc=protoc-gen-grpc,

reproduction using direct protoc call:

$ protoc --grpc_out=/tmp --plugin=protoc-gen-grpc=protoc-gen-grpc src/grpc/proto/io/grpc/testing/integration/empty.proto
protoc-gen-grpc: 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.
YifeiZhuang commented 1 year ago

The error in https://github.com/google/protobuf-gradle-plugin/issues/699#issuecomment-1537055608 is gone when the the plugin executable is in the current build directory! But if the plugin in the system search PATH, it fails with program not found or is not executable.

@andrew-teirney could you show your configuration and more detailed gradle build error? I can't reproduce your error.

ateirney commented 1 year ago

I have just created a sample project that I believe reproduces my error.

https://github.com/ateirney/google-protobuf-issue.git is the repository with the replication of the issue.

If I attempt to add an executable locator using the below construct I get the error you encountered above. Historically I have not had to provide an executable locator.

protobuf {
    ...
    plugins {
        id("bq-schema") {
        }
    }
    ...
}
ateirney commented 1 year ago

Further to the above, in an older version of the plugin (specifically 0.8.2) without providing an executable locator the following would be emitted.

protoc plugin 'bq-schema' not defined. Trying to use 'protoc-gen-bq-schema' from system path

YifeiZhuang commented 1 year ago

Thank you @ateirney, I can also reproduce and verify your fix.