grpc-kotlin: protoc-gen-grpckt: program not found or is not executable

After following the steps in the README.md file I am not able to generate the proto files from the command line

git clone git@github.com:grpc/grpc-kotlin.git
cd grpc-kotlin/
./gradlew build
vi test.proto // make some test proto file
mkdir testDir
protoc --plugin=protoc-gen-grpc-kotlin=build/artifacts/protoc-gen-grpc-kotlin --grpckt_out=testDir --proto_path=. test.proto

And the result from this is

protoc-gen-grpckt: 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
--grpckt_out: protoc-gen-grpckt: Plugin failed with status code 1.

protoc version - 3.11.4

image

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 1
  • Comments: 27

Commits related to this issue

Most upvoted comments

@jamesward alternatively you can prepend the shebang on *nix systems:

$ cat <(echo '#!/usr/bin/java -jar') protoc-gen-grpc-kotlin-0.2.1-jdk7.jar > protoc-gen-grpc-kotlin.jar
$ ./protoc-gen-grpc-kotlin.jar

0.1.5 is working as binary but the build jar for 0.2.0 is not working.

Download URL: https://repo1.maven.org/maven2/io/grpc/protoc-gen-grpc-kotlin/0.2.0/protoc-gen-grpc-kotlin-0.2.0-jdk7.jar

Tried chmod +x on the jar file without success.

root@8526a5721d90:/check# ls /usr/local/bin/
 acountry   ahost   grpc_cpp_plugin      grpc_node_plugin          grpc_php_plugin      grpc_ruby_plugin   omniproto   protoc-3.13.0.0   protoc-gen-go        protoc-gen-gogo       protoc-gen-grpc-java         protoc-gen-lint   protoc-gen-scala  ''$'\377\200'
 adig       buf     grpc_csharp_plugin   grpc_objective_c_plugin   grpc_python_plugin   grpc_web_plugin    protoc      protoc-gen-doc    protoc-gen-go-grpc   protoc-gen-gogofast   protoc-gen-grpc-kotlin.jar   protoc-gen-rbi    protoc-gen-ts
root@8526a5721d90:/check#


root@8526a5721d90:/check# protoc --grpc-kotlin_out=testDir --proto_path=. test.proto
protoc-gen-grpc-kotlin: 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-kotlin_out: protoc-gen-grpc-kotlin: Plugin failed with status code 1.
root@8526a5721d90:/check#


root@8526a5721d90:/check# protoc --plugin=protoc-gen-grpc-kotlin="java -jar /usr/bin/protoc-gen-grpc-kotlin.jar" --grpc-kotlin_out=testDir --proto_path=. test.proto
java -jar /usr/bin/protoc-gen-grpc-kotlin.jar: 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-kotlin_out: protoc-gen-grpc-kotlin: Plugin failed with status code 1.
root@8526a5721d90:/check#

Here are some execution tests:

root@8526a5721d90:/usr/local/bin# chmod +x protoc-gen-grpc-kotlin.jar
root@8526a5721d90:/usr/local/bin# ./protoc-gen-grpc-kotlin.jar
./protoc-gen-grpc-kotlin.jar: line 1: $'PK\003\004': command not found
./protoc-gen-grpc-kotlin.jar: line 2: $'\b\bY0Q\002': command not found
K-*ϳR03-IM+I,: No such file or directory]nMETA-INF/MANIFEST.MFMLK-.
./protoc-gen-grpc-kotlin.jar: line 12: Q4ȴ No such file or directory
./protoc-gen-grpc-kotlin.jar: line 13: $'\215x\353v\a\303~_\240nH\r\250!O8\030\252\333\200\336\346': command not found
./protoc-gen-grpc-kotlin.jar: line 12: $'@[\3154\257=\030\032\252\333\245\206\373C\036_@\253\363\004\002\301\260\361\266\2563\030\356\214\370\375\030%k\306J\026\2620\235e\202\3365:\347\v\204\325P\300\343\257s\005\302!\314\367y5\231\024\246\323\274': command not found
./protoc-gen-grpc-kotlin.jar: line 12: $'U\357\356\315XhX\305\b\227f\302b\232_\335\276\3133\352\251\363{\002Cu]\375\273ToxuR\217[\200\031Z\275': command not found
@Ҿy9Vtoc-gen-grpc-kotlin.jar: line 12: $
zEz%9yzyE%Ez0VPiPK
\Y0Qio/PK
\Y0io/grpc/PK
\Y0Qio/grpc/kotlin/PK
\Y0Qio/grpc/kotlin/generator/PK
21ShWmISio/grpc/kotlin/generator/GrpcCoroutineServerGenerator.class[    (       [
C~n$
F0A4$V/hϸ^=TP)MaZϦ*: No such file or directory
./protoc-gen-grpc-kotlin.jar: line 13: syntax error near unexpected token `)'
./protoc-gen-grpc-kotlin.jar: line 13: `z3|uLdFәJ|#fGӘmOR##&f#A5\׳DuVI)$g`@`>S:f*;bZR'{t@L>r =ӊ(
o46}yu-Vj!Ζi    Z`b4JLhB                                                                        pV*=-L*cr]Y.i0MHMZz|djF͢0gvB7eZ4eH
                        0q}GXT'LV2){}oSk$PujV$lwHiȥ-}ZKG'
root@8526a5721d90:/usr/local/bin#

@eleduardo What version of the protoc gradle plugin are you using? You need to have at least 0.8.13. I’ll add that note to the new README.

Ah, so I have a better understanding now of what is going on. Thanks all for providing more details. So the way that the Gradle protoc plugin is able to have protoc-gen-grpc-kotlin.jar called as a command is that it sticks some stuff at the beginning of the file to make it work as an executable. (Note: I’m not sure how the Maven plugin makes things work but somehow it does.)

For those who want to call protoc-gen-grpc-kotlin.jar without using Gradle or Maven build plugins then you’ll have to create a shell script that does the java -jar thing and tell protoc to call your shell script. I think that we should investigate releasing some artifacts that are executable but that is going to take a decent amount of work. (Note: I think a newer version of Java has an easier way to do this.)

For now we do need to update the README with correct info.

I am having the same problem, even running every single step that is show in the README and trying to compile one of the proto files in the test directory

@eleduardo Great! I’ve added that to the updated README. Thanks for helping us improve this.

@jamesward Just FYI, getting the same problem using the gradle proto plugin

protobuf {
    protoc {
        artifact = "com.google.protobuf:protoc:3.6.1"
    }
    plugins {
        id("grpc") {
            artifact = "io.grpc:protoc-gen-grpc-java:1.32.1"
        }
        id("grpckt") {
//            artifact = "io.grpc:protoc-gen-grpc-kotlin:0.2.1:jdk7@jar"
            artifact = "io.grpc:protoc-gen-grpc-kotlin:0.1.5"
        }
    }
    generateProtoTasks {
        all().forEach {
            it.plugins {
                id("grpc")
                id("grpckt")
            }
        }
    }
}

Notice I commented out the 0.2.1 version, if I use 0.1.5 it works but 0.2.1 also gets the

Execution failed for task ':generateProto'.
> protoc: stdout: . stderr: customer_data/audience/v1beta/audience.proto: warning: Import google/protobuf/timestamp.proto but not used.
  /Users/eduardo.solis/.gradle/caches/modules-2/files-2.1/io.grpc/protoc-gen-grpc-kotlin/0.2.1/cba706ec15a0efa4dbd8bdd8396f97aa984ac589/protoc-gen-grpc-kotlin-0.2.1-jdk7.jar: program not found or is not executable
  --grpckt_out: protoc-gen-grpckt: Plugin failed with status code 1.

but using 0.1.5 works

Any update on this the version “0.2.1” also has the same issue.

I followed the first set of instructions, installing from https://mvnrepository.com/artifact/io.grpc/protoc-gen-grpc-kotlin, and had similar issues to this issue.

The issue is that the docs, and the instructions here, includes the flag —grpckt_out=testDir. protoc tries to find a plugin called protoc-gen-grpckt, which it finds either through the plugins list, or a binary (in $PATH). In this case, protoc can’t find either and bombs out.

To fix, either run:

protoc --plugin=protoc-gen-grpc-kotlin=build/artifacts/protoc-gen-grpc-kotlin --grpc-kotlin_out=testDir --proto_path=. test.proto

Or:

protoc --plugin=protoc-gen-grpckt=build/artifacts/protoc-gen-grpc-kotlin --grpckt_out=testDir --proto_path=. test.proto

Or, install the plugin from the above url using something like:

$ wget https://repo1.maven.org/maven2/io/grpc/protoc-gen-grpc-kotlin/0.1.5/protoc-gen-grpc-kotlin-0.1.5-linux-x86_64.exe -O /usr/bin/protoc-gen-grpc-kotlin
$ chmod 0755 /usr/bin/protoc-gen-grpc-kotlin

At which point the command becomes something like:

protoc --grpc-kotlin_out=testDir --proto_path=. test.proto

(Note the lack of the —plugin opt)

OS: OSX Catalina Protoc: 3.12.1

Running from Gradle following those steps: https://github.com/grpc/grpc-kotlin/tree/master/compiler#compiling-and-testing-the-codegen. + …/gradlew prependShellStub

Also trying the pre-compiled binary following those steps: https://github.com/grpc/grpc-kotlin/tree/master/compiler#grpc-kotlin-codegen-plugin-for-protobuf-compiler

Am not a Kotlin/Java dev myself so I might be missing something.

We probably need to add to the README but you need to run: ../gradlew prependShellStub

Otherwise the artifacts are not runnable.