Protoc-gen-nanopb: program not found or is not executable

2,523 views
Skip to first unread message

sondre....@gmail.com

unread,
Aug 28, 2017, 2:38:03 AM8/28/17
to nanopb
Hi guys,

I've successfully used nanopb on a raspberry pi for a couple of months. Now I changed hardware to the NVIDIA TX1 and I have some problems generating pb files.

This is the commando I've used all the time:
protoc --plugin=protoc-gen-nanopb=Protobuf/nanopb-master/generator/protoc-gen-nanopb --nanopb_out=. RobotCmdData.proto

On the raspberry pi this generates the pb files successfully, but on the NVIDIA TX1 I get the following error:
Protobuf/nanopb-master/generator/protoc-gen-nanopb: program not found or is not executable
--nanopb_out: protoc-gen-nanopb: PLugin failed with status code 1

However, when running ls -la the file is found and is executable
ls -la Protobuf/nanopb-master/generator/protoc-gen-nanopb
-rwxr-xr-x 1 ubuntu ubuntu 480 Apr 19 13:04 Protobuf/nanopb-master/generator/protoc-gen-nanopb (in green text)

I also tried to give the absolute path, but I receive the same error. Does anyone have an idea of what causing the error?

Best regards
Sondre

Petteri Aimonen

unread,
Aug 28, 2017, 2:55:23 AM8/28/17
to nan...@googlegroups.com
Hi

> I also tried to give the absolute path, but I receive the same error.
> Does anyone have an idea of what causing the error?

Does the generator work when run separately outside protoc? Like:
python nanopb/generator/nanopb_generator.py

What about this one, it should say "DecodeError: Truncated message":
echo | generator/protoc-gen-nanopb

Your error message is coming from here and should only be reached it
execvp() returns, which it does only on error, but hard to say what
error it encounters:
https://github.com/google/protobuf/blob/ba4e54724d2e6a1881c4fe88664d81fbacaf8c08/src/google/protobuf/compiler/subprocess.cc#L340

--
Petteri

sondre....@gmail.com

unread,
Aug 28, 2017, 3:14:27 AM8/28/17
to nanopb, j...@kapsi.fi
Hi Petteri,

Thank you for your quick response!

> Does the generator work when run separately outside protoc? Like:
> python nanopb/generator/nanopb_generator.py

python Protobuf/nanopb-master/generator/nanopb_generator.py
Usage: nanopb_generator.py [options] file.pb ...

Options:
-h, --help show this help message and exit
-x FILE Exclude file from generated #include list.
-e EXTENSION, --extension=EXTENSION
Set extension to use instead of '.pb' for generated
files. [default: .pb]
-f FILE, --options-file=FILE
Set name of a separate generator options file.
-I DIR, --options-path=DIR
Search for .options files additionally in this path
-D OUTPUTDIR, --output-dir=OUTPUTDIR
Output directory of .pb.h and .pb.c files
-Q FORMAT, --generated-include-format=FORMAT
Set format string to use for including other .pb.h
files. [default: #include "%s" ]
-L FORMAT, --library-include-format=FORMAT
Set format string to use for including the nanopb pb.h
header. [default: #include <%s> ]
-T, --no-timestamp Don't add timestamp to .pb.h and .pb.c preambles
-q, --quiet Don't print anything except errors.
-v, --verbose Print more information.
-s OPTION:VALUE Set generator option (max_size, max_count etc.).

Compile file.pb from file.proto by: 'protoc -ofile.pb file.proto'. Output will
be written to file.pb.h and file.pb.c.

> What about this one, it should say "DecodeError: Truncated message":
> echo | generator/protoc-gen-nanopb

echo | Protobuf/nanopb-master/generator/protoc-gen-nanopb
bash: Protobuf/nanopb-master/generator/protoc-gen-nanopb: /bin/sh^M: bad interpreter: No such file or directory

Sondre

Petteri Aimonen

unread,
Aug 28, 2017, 6:26:01 AM8/28/17
to nan...@googlegroups.com
Hi,

> echo | Protobuf/nanopb-master/generator/protoc-gen-nanopb
> bash: Protobuf/nanopb-master/generator/protoc-gen-nanopb: /bin/sh^M: bad interpreter: No such file or directory

Ah, looks like the file protoc-gen-nanopb has at some point been passed
through a windows machine. The ^M indicates a windows-style newline
character in the file, which is not allowed by Linux on a shebang line.

Try either downloading it fresh from github, or alternatively converting
it to unix format with "dos2unix". Note that you may have the same issue
with nanopb_generator.py.

--
Petteri

sondre....@gmail.com

unread,
Aug 28, 2017, 7:09:39 AM8/28/17
to nanopb, j...@kapsi.fi
Of course! You are completely right!

Thank you so much, Petteri :)

Best regards
Sondre

Reply all
Reply to author
Forward
0 new messages