2
syntax = "proto3";

package model;

import "google/protobuf/Empty.proto";

message User {
    string id = 1;
    string name  = 2;
    string email = 3;
    string alamat = 4;
    string password = 5;
}

message UserList {
    repeated User list = 1;
}

message userId {
    string id = 1; 
}

message UserUpdate {
    string id = 1;
    User user = 2;
}

service Users {
    rpc getUserList(google.protobuf.Empty) returns (UserList) {}
    rpc getUserById(userId) returns (User) {}
    rpc inserUser(User) returns (google.protobuf.Empty) {}
    rpc updateUser(UserUpdate) returns (google.protobuf.Empty) {} 
    rpc deleteUser(userId) returns (google.protobuf.Empty) {}  
}

above is my proto file. I get error google/protobuf/Empty.proto: File not found. when trying to compile the proto file above. can someone help me ?

0

4 Answers 4

4

First of all, the correct import is import "google/protobuf/empty.proto";

second, for generating a proto file run this code:

protoc --proto_path={proto_directory_address} --proto_path={proto_directory_name} --go-grpc_out={generated_directory_path} --go_out={generated_directory_path} {proto_directory_address}/{proto_file_name}.proto

1
  • I believe it's --go_grpc_out with an underscore, not --go-grpc_out
    – Agile Bean
    Commented Dec 26, 2023 at 9:23
4

I had the same problem because I had not installed the protoc correctly

For successful installation do these steps:

  1. Download latest version from here https://github.com/protocolbuffers/protobuf/releases
  2. Extract in your computer
  3. move bin/protoc to /usr/local/bin
sudo mv {downloaded_directory}/bin/protoc /usr/local/bin
  1. move include folder to /usr/local
sudo mv {downloaded_directory}/include /usr/local
2
  • 1
    I had to add --proto_path=/usr/local/include/:. otherwise it wouldn't see the path at all. The :. is so it looks in the current dir also, otherwise it won't see your proto file
    – MikeKulls
    Commented Oct 4, 2023 at 3:01
  • @MikeKulls I just import "google/protobuf/empty.proto" to the proto file Commented Feb 4 at 9:28
0

hi there / i had the same issue for a long time .. this process worked for me i hope it dose for you too : navigate to this directory using your cmd(command line) :

cd .local/include

this directory normally should contain some folder named "google" copy this folder and paste it to this directory :

/usr/local/include

and now try the protoc engine again to generate your project and if the error still exists then try the rest of process :

navigate to that specific directory and check if its been copied or not . if it is then try to navigate to the folder from where you are (which it should be /usr/local/include) if the error says you have no permission to get in the folder use this command to get the permission

$ sudo chmod o+r -R ./google

and then try to get permission to get in protobuf folder in the same directory using above command again when its all done . check the protoc generator again /// hope works for you because it dose for me

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Feb 4, 2023 at 16:40
-4

import public "google/protobuf/empty.proto";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.