ruby-protobuf icon indicating copy to clipboard operation
ruby-protobuf copied to clipboard

Multi Require causes exception

Open samhendley opened this issue 14 years ago • 4 comments

Hi Macks, I mentioned an issue in my pull request. This error has been present for a while but is really pronounced in the eval() done to verify that the file created is able to be loaded. Basically the protobuf classes are not tolerant of being re-required.

http://gist.github.com/407742

What I think it should do is probably throw away the old definition if it is re-required but I wanted to get your opinion and input on the cleanest way to do that rather than go in with a machete myself.

samhendley avatar May 20 '10 16:05 samhendley

Hi Macks, I do suffer the same problem. I'm using it in Rails 3, and there is loads of require magic going on, everything works fine, but deployed application is raising TagCollisionError. I tried locally to re-require my protobuf models, and indeed they are raising this exception.

skrat avatar Nov 10 '10 18:11 skrat

I am also having this problem. Using Rails3/Ruby 1.8.7 when classes are not cached it appears it re-requires the pb.rb which causes a collision:

/Library/Ruby/Gems/1.8/gems/ruby_protobuf-0.4.9/lib/protobuf/message/message.rb:43:in `define_field': Field tag 1 has already been used in NameSpace::Object. (Protobuf::TagCollisionError)

yanks avatar Feb 24 '11 02:02 yanks

I've tried to fix this bug with that commit : https://github.com/vivrass/ruby-protobuf/commit/862aed177921b1fc235b668a46d5c79d36b00d06

After trying my fix, I saw that was not the problem in my application so I cannot confirm that it is working. You can try it to verify if you want.

vivrass avatar Sep 20 '11 18:09 vivrass

Has anyone tried @vivrass's suggested fix?

AndydeCleyre avatar Dec 07 '16 20:12 AndydeCleyre