grpc-kotlin icon indicating copy to clipboard operation
grpc-kotlin copied to clipboard

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

Open KristiyanGergov opened this issue 5 years ago • 27 comments
trafficstars

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

git clone [email protected]: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

KristiyanGergov avatar May 16 '20 05:05 KristiyanGergov

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

Otherwise the artifacts are not runnable.

jamesward avatar May 18 '20 16:05 jamesward

Hi!

Am having the same issue I tried the suggested solution compiling the code gen locally but, I got the same result described in the original question I also tried to use the pre-compiled binary, made it executable but, also got the same error

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.

mhd999 avatar Jun 17 '20 13:06 mhd999

@mhd999 What operating system? Is this when running from Gradle / Maven or somehow else?

jamesward avatar Jun 17 '20 14:06 jamesward

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.

mhd999 avatar Jun 17 '20 14:06 mhd999

So you are doing something like:

protoc --plugin=protoc-gen-grpc-kotlin=build/artifacts/protoc-gen-grpc-kotlin \
  --grpckt_out="$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"

What happens if you do:

echo "asdf" | build/artifacts/protoc-gen-grpc-kotlin

jamesward avatar Jun 22 '20 15:06 jamesward

I got exec format error: build/artifacts/protoc-gen-grpc-kotlin

mhd999 avatar Jun 25 '20 08:06 mhd999

Very strange. If you less the file you should see something like this at the top:

#!/bin/sh

exec java -jar $0
PK^C^D

The prependShellStub task should be putting that little script snippet at the beginning of the Jar. Can you verify that is happening?

jamesward avatar Jun 25 '20 14:06 jamesward

Same issue here

hijamoya avatar Jun 29 '20 02:06 hijamoya

@jamesward less protoc-gen-grpc-kotlin

it start with PK^C^D no

#!/bin/sh

exec java -jar $0

mhd999 avatar Jul 03 '20 10:07 mhd999

Odd. Did anything come after that? Also what happens if you do:

unzip -l build/artifacts/protoc-gen-grpc-kotlin

jamesward avatar Jul 06 '20 14:07 jamesward

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)

jspc avatar Aug 18 '20 11:08 jspc

@jspc That worked for me. protoc --plugin=protoc-gen-grpc-kotlin=protoc-gen-grpc-kotlin-0-1-3 --grpc-kotlin_out=PATH_TO/kotlin --proto_path=PATH_TO/service.proto

However, it only generates two files 1- ServiceImplBase.kt 2- ServiceStubExt.kt

ServiceGrpcKt is missing.

mhd999 avatar Sep 07 '20 12:09 mhd999

@jspc

I followed the first set of instructions

Which instructions are those? Are you not using Maven or Gradle to do the protoc generation?

jamesward avatar Sep 08 '20 18:09 jamesward

I'm encountering a similar issue when trying to use kotlin plugin with https://github.com/grpckit/omniproto:

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

The arguments are as follow:

 --go_out=paths=source_relative:gen-go --go-grpc_out=paths=source_relative:gen-go --java_out=gen-java --grpc-kotlin_out=gen-kotlin-grpc --descriptor_set_out=gen/descriptors.pb --include_imports 

Tried with prependShellStub but I got:

* What went wrong:
Task 'prependShellStub' not found in project ':grpc-kotlin-compiler'.

Any ideas?

mgenov avatar Sep 28 '20 06:09 mgenov

I'm still a bit confused by what path people are taking to run into this. Why not just use the protoc plugin from Maven Central?

@mgenov Why are you building the grpc-kotlin-compiler on your own instead of using the published artifact?

jamesward avatar Oct 05 '20 22:10 jamesward

As I remember I had a similar result and from build in maven central. I'll try again and will post the results later today.

mgenov avatar Oct 06 '20 05:10 mgenov

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#

mgenov avatar Oct 07 '20 19:10 mgenov

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

stephaniemulder avatar Nov 08 '20 12:11 stephaniemulder

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

elbaulp avatar Nov 12 '20 12:11 elbaulp

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.

jamesward avatar Nov 17 '20 22:11 jamesward

I have a PR to improve the compiler readme. Can anyone that's had issues with this check it out: https://github.com/grpc/grpc-kotlin/blob/4cc534adafa518460700eafc7a54de42cb829df5/compiler/README.md And let me know if it helps: https://github.com/grpc/grpc-kotlin/pull/207

jamesward avatar Nov 18 '20 23:11 jamesward

@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

nbaztec avatar Nov 19 '20 10:11 nbaztec

@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

eleduardo avatar Nov 19 '20 15:11 eleduardo

@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.

jamesward avatar Nov 19 '20 15:11 jamesward

@jamesward thank you that was it! sorry! 0.8.9 is what I was using but bumping it up to 0.8.14 worked

eleduardo avatar Nov 19 '20 15:11 eleduardo

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

jamesward avatar Nov 19 '20 15:11 jamesward

@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.

Ran into the same problem and wanted to confirm this fixed it for me.

RdeWilde avatar Jan 15 '21 21:01 RdeWilde