From 4c445b18038b843588a2298b423d27b0d97cef1e Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 19 Oct 2021 14:51:52 -0700 Subject: [PATCH] Fix for descriptor_pb.rb: google/protobuf should be required first. --- src/google/protobuf/compiler/ruby/ruby_generator.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/google/protobuf/compiler/ruby/ruby_generator.cc b/src/google/protobuf/compiler/ruby/ruby_generator.cc index c1a5c67d2ac23..6f718cfd5af59 100644 --- a/src/google/protobuf/compiler/ruby/ruby_generator.cc +++ b/src/google/protobuf/compiler/ruby/ruby_generator.cc @@ -467,8 +467,6 @@ void EndPackageModules(int levels, io::Printer* printer) { bool GenerateDslDescriptor(const FileDescriptor* file, io::Printer* printer, std::string* error) { - printer->Print( - "require 'google/protobuf'\n\n"); printer->Print("Google::Protobuf::DescriptorPool.generated_pool.build do\n"); printer->Indent(); printer->Print("add_file(\"$filename$\", :syntax => :$syntax$) do\n", @@ -509,6 +507,9 @@ bool GenerateFile(const FileDescriptor* file, io::Printer* printer, "\n", "filename", file->name()); + printer->Print( + "require 'google/protobuf'\n\n"); + for (int i = 0; i < file->dependency_count(); i++) { printer->Print("require '$name$'\n", "name", GetRequireName(file->dependency(i)->name())); }