Given this schema:
syntax = "proto3";
message Container {
repeated Thing things = 1;
}
message Thing {
string name = 1;
}
This works on Linux:
irb(main):019:0> Container.new(things: [{name: "something"}])
=> <Container: things: [<Thing: name: "something">]>
This is the result on OS X (Ruby 2.5.1):
irb(main):017:0> Container.new(things: [{name: "something"}])
Traceback (most recent call last):
5: from /Users/stuart/.rubies/ruby-2.5.1/bin/irb:11:in `<main>'
4: from (irb):17
3: from (irb):17:in `new'
2: from (irb):17:in `initialize'
1: from (irb):17:in `msgclass'
ArgumentError (wrong number of arguments (given 11760, expected 0))
This worked for me on OS X on Ruby 2.4.3, but broke when I upgraded to Ruby 2.5.1.
Gem version: 3.5.1.2
I'll add a conformance test for ruby2.5 on Mac and check it.
@TeBoring Can we get a status update on this?
Hi! We're experiencing same problem however looks like number of "wrong" arguments is different. (proto is not same as in first comment)
Traceback (most recent call last):
4: from (irb):1
3: from (irb):1:in `new'
2: from (irb):1:in `initialize'
1: from (irb):1:in `msgclass'
ArgumentError (wrong number of arguments (given 234053632, expected 0))
Maybe it will help debugging :)
We will also see a negative argument count.
ArgumentError (wrong number of arguments (given -8532890532, expected 0))
I am debugging it.
Mac Version: 10.13.6
ruby version: 2.5.1p57
gem version: 2.7.6
protobuf version: master (3.6.1)
Use the same proto file and ruby code in the post.
Everything works.
Is it a deterministic failure?
I just tested again with gem version 3.6.1. It still fails consistently for me, though the "number of arguments" in the error message seems to vary.
We see this constantly as well.
I build protobuf_c.bundle locally and use it to replace the one install by gem install and it works. So I think there is some problem with our artifact build.
Work around:
gem installThe above solves the problem for me, but I have realised that I used google-protobuf-3.6.1-universal-darwin. When I switched to gem google-protobuf-3.6.1 in my project, the issue was solved anyway. It looks like gem version google-protobuf-3.6.1-universal-darwin includes the compiled files, while google-protobuf-3.6.1 compiles it on your machine and this may be the cause.
Big props for @romanoji, worked this out together.
I am using:
Mac OS: 10.12.6
Ruby version: 2.5.1
Google-protobuf gem version: 3.6.1
To force using ruby platform gems in bundler, use bundle config force_ruby_platform true.
Will there be an updated google-protobuf-3.6.X-universal-darwin published @TeBoring?
Yeah, probably 3.6.1.1
Hello @TeBoring, any idea when the 3.6.1.1 release will be published? Thanks!
@TeBoring sorry to be a squeaky wheel here, but for various reasons we're unable to use the workaround above (https://github.com/protocolbuffers/protobuf/issues/4469#issuecomment-420581749). It works for our local development, but we need to use the precompiled linux version (google-protobuf (3.6.1-x86_64-linux)) in our actual deployments so we run into problems later. So, for us, this means we're blocked on our Ruby 2.5.x upgrade. 馃槥
Do you have an estimate for when you think the fix for OSX will be released? Thanks, we appreciate it!!
Fixed by #5519
Will release a fixed gem for 3.7 release.
Thank you, @TeBoring! Can't wait to start out the new year with a shiny new google-protobuf gem. 馃槃 馃帀 馃拵 馃帀
@TeBoring How does #5519 fix this issue? Does compiling against 2.5.1 fix this?
Also, would it be possible to add support for Ruby 2.6.0 before 3.7.0 is released?
Using ruby2.5.1 to build the gem fix the issue.
I am working on 2.6 support
Most helpful comment
The above solves the problem for me, but I have realised that I used
google-protobuf-3.6.1-universal-darwin. When I switched to gemgoogle-protobuf-3.6.1in my project, the issue was solved anyway. It looks like gem versiongoogle-protobuf-3.6.1-universal-darwinincludes the compiled files, whilegoogle-protobuf-3.6.1compiles it on your machine and this may be the cause.Big props for @romanoji, worked this out together.
I am using:
Mac OS: 10.12.6
Ruby version: 2.5.1
Google-protobuf gem version: 3.6.1
To force using ruby platform gems in bundler, use
bundle config force_ruby_platform true.