Closed k0ff33 closed 6 years ago
Protocol doesn't know where to find our specific extensions, so you need to extend the "proto path" to include the options proto, the example script does it by: https://github.com/firebase/protobuf-rules-gen/blob/7a8fde451153a2d5de6f0c2597e06faeba245604/example_usage.sh#L37
So if you are trying to import just the file, you'll need to add the directory containing the file to the proto path using the flag I pointed you too.
Let me know if that works!
Ok, that makes sense, thanks. I ended up using two --proto_path parameters, one to a clone of this repo and one to my project as such:
protoc --firebase_rules_out=. --proto_path=/Users/kamilwojtczyk/Developer/open-source/protobuf-rules-gen/proto/ --proto_path=. firestore.proto
Now I'm getting errors about other includes, where can I get those? They don't seem to be part of protoc
package.
google/protobuf/descriptor.proto: File not found.
firebase_rules_options.proto: Import "google/protobuf/descriptor.proto" was not found or had errors.
firebase_rules_options.proto:24:8: "google.protobuf.MessageOptions" is not defined.
firebase_rules_options.proto:28:8: "google.protobuf.FieldOptions" is not defined.
firebase_rules_options.proto:32:8: "google.protobuf.FileOptions" is not defined.
firebase_rules_options.proto:36:8: "google.protobuf.EnumOptions" is not defined.
firestore.proto: Import "firebase_rules_options.proto" was not found or had errors.
https://github.com/google/protobuf/tree/master/src/google/protobuf
They are in the protobuf repo. Depending how it got installed, you may or may not have them. If you clone that repo, just add the src/ directory to the proto path.
I'm going to try to update the README to make this more clear, thanks for bring this up!
Thanks, adding another --proto_path to protobuf/src fixes the problem. I currently invoke protoc with 3 proto_path(s) pointing to protobuf/src, protobuf-rules-gen/proto and current working folder like:
protoc --firebase_rules_out=. --proto_path=/Users/kamilwojtczyk/Developer/open-source/protobuf/src/ --proto_path=/Users/kamilwojtczyk/Developer/open-source/protobuf-rules-gen/proto/ --proto_path=. firestore.proto
Regarding the way it was installed, I just followed the guide from repo's readme:
PS. I'm looking forward to seeing timestamps in the future. Great work!
Awesome, I'm glad that worked, I'm going to close this with the PR to update the documentation, let me know if that is sufficient!
PS. Please open another issue for timestamps and I'll get to it
Hey, first and foremost thanks for the tool, it makes building Firestore security rules more intuitive.
I have a slight problem with installing it correctly though. I've followed the instruction notes, installed last release version of protoc, copied content of include folder to
/usr/local/include
and added both protoc and plugin binary to my $PATH.It works fine with simple examples that don't
import "firebase_rules_options.proto";
(first example with proto2 syntax), however, trying something more complex with the ^ import results in:I've tried using the
--plugin=protoc-gen-firebase_rules=
flag as well with no luck.Do you have an idea what is wrong here? I guess it's more of a protobuf issue rather than plugin-related, but wanted to ask here first.
I've found a similar issue on stackoverflow but the proposed solutions didn't work either. I guess it's definitely to do with
/usr/local/include
not being included but I'm not a C++ user and have no idea how to fix that. Thanks.