1

I have created a virtualenv with python3. Inside the vitual environment, I have 2 proto files in my folder along with nanopb package. The structure is

.
├── api.pb
├── api.proto
├── bin
├── compile.sh
├── include
├── lib
├── nanopb-0.4.2-linux-x86
└── types.proto

As first step i compiled types.proto and api.proto into api.pb using the command

./nanopb-0.4.2-linux-x86/generator-bin/protoc -I=./nanopb-0.4.2-linux-x86/generator/proto -I=. api.proto -o api.pb

Once the pb file is generated I executed the following command,

python nanopb-0.4.2-linux-x86/generator/nanopb_generator.py /home/ankit/Desktop/api/venv-proto-3/api.pb

which gives the following error

(venv-proto-3) ankit@ankit-desktop:~/.../api/venv-proto-3$ python nanopb-0.4.2-linux-x86/generator/nanopb_generator.py /home/ankit/Desktop/api/venv-proto-3/api.pb
Writing to api.pb.h and api.pb.c
Traceback (most recent call last):
  File "nanopb-0.4.2-linux-x86/generator/nanopb_generator.py", line 2122, in <module>
    main_cli()
  File "nanopb-0.4.2-linux-x86/generator/nanopb_generator.py", line 2034, in main_cli
    os.makedirs(os.path.dirname(path), exist_ok=True)
  File "/home/ankit/Desktop/api/venv-proto-3/lib/python3.5/os.py", line 241, in makedirs
    mkdir(name, mode)
FileNotFoundError: [Errno 2] No such file or directory: ''
(venv-proto-3) ankit@ankit-desktop:~/.../api/venv-proto-3$ 

Any idea what I am doing wrong here. Pretty new to protobuf.

Thanks

jpa
  • 10,351
  • 1
  • 28
  • 45
Ankit
  • 431
  • 2
  • 5
  • 18

1 Answers1

0

Sorry, this is a bug in 0.4.2 version. As a workaround you can add --output_dir=. like Azeem suggested.

I've added it to the issue tracker here: https://github.com/nanopb/nanopb/issues/553

It's silly that I missed that very basic case in unittests.

jpa
  • 10,351
  • 1
  • 28
  • 45
  • @Ankit If you can try newest build from https://jpa.kapsi.fi/jenkins/job/nanopb/job/nanopb%20linux/ it would be helpful. – jpa Jun 27 '20 at 19:51