flutterdartbackendprotocol-bufferscode-generation

ZHS Permission Problem on Proton generation on MacM1


I am using Apple MacBook Air with M2 Chip to develop softwares and etc. Currently my company using protocol buffers to serialize entity models. I am having issues with generating Dart files through using protoc.

I used $ brew install protobuf and run $ protoc --version to check installation. Terminal prompts libprotoc 23.4.

However, when I use following code block to generate files,

mkdir lib/src/shared/dart_gen

protoc --dart_out=grpc:lib/src/shared/dart_gen --proto_path=lib/src/shared/proto `
    lib/src/shared/proto/shared.proto `
    lib/src/shared/proto/consumer/consumer.proto `
    lib/src/shared/proto/order/order.proto `

Terminal promts

mkdir: lib/src/shared/dart_gen: File exists
zsh: permission denied: lib/src/shared/proto/shared.proto
Missing input file.
zsh: permission denied: lib/src/shared/proto/order/order.proto
zsh: permission denied: lib/src/shared/proto/consumer/consumer.proto

Note:

  • I tried Give Terminal Full Access to the Disk from Privacy and Security Settings and it didn't work.

I tried to generate some Proto-dart files through using protoc on terminal.(Apple M2 Chip)


Solution

  • I do not know why, but it was never about the permissions. I used followings to solved the issue mkdir lib/src/shared/dart_gen protoc --dart_out=grpc:lib/src/shared/dart_gen --proto_path=lib/src/shared/proto lib/src/shared/proto/*/*.proto for lib/src/shared/proto has multiple folders that contains balbla.proto files –