Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--ruby-out does not invoke protoc-gen-ruby for protoc v3 #341

Closed
ebenoist opened this issue Oct 21, 2016 · 6 comments
Closed

--ruby-out does not invoke protoc-gen-ruby for protoc v3 #341

ebenoist opened this issue Oct 21, 2016 · 6 comments

Comments

@ebenoist
Copy link

Hi Friends-

With the protobuf v3 out, the official google compiler invokes its internal ruby compiler for v3 protof files with the --ruby_out option instead of protoc-gen-ruby. I'm not ready to switch to v3 yet (or Google's compiler) and would love to continue using this project.

I can force this to work by renaming the flag to --ruby2_out for example and by changing the name of the binary to protoc-gen-ruby2 this works fantastically even with the newest compiler. Any thoughts on how both of these compilers can continue to live together. This project is invaluable because of its proto2 support.

If there's consensus around an approach, I'd be happy to put up a PR.

@ebenoist ebenoist changed the title --ruby-out does not envoke protoc-gen-ruby for protoc v3 --ruby-out does not invoke protoc-gen-ruby for protoc v3 Oct 21, 2016
@brianvh
Copy link

brianvh commented Mar 15, 2017

I haven attempted to replicate these steps, using the current 3.6.12 release, and all I get is an immediate Exception, from the Gem::Specification layer:

[hd]: protoc --ruby2_out=lib -I definitions definitions//foo.proto
/Users/brianvh/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/specification.rb:2158:in `method_missing': undefined method `this' for #<Gem::Specification:0x3fc3d049b424 protobuf-3.6.12> (NoMethodError)
	from /Users/brianvh/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/specification.rb:1057:in `find_active_stub_by_path'
	from /Users/brianvh/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:64:in `require'
	from /Users/brianvh/.rvm/gems/ruby-2.3.0@hr-api/gems/protobuf-3.6.12/bin/protoc-gen-ruby:9:in `<top (required)>'
	from /Users/brianvh/.rvm/gems/ruby-2.3.0@hr-api/bin/protoc-gen-ruby2:23:in `load'
	from /Users/brianvh/.rvm/gems/ruby-2.3.0@hr-api/bin/protoc-gen-ruby2:23:in `<main>'
	from /Users/brianvh/.rvm/gems/ruby-2.3.0@hr-api/bin/ruby_executable_hooks:15:in `eval'
	from /Users/brianvh/.rvm/gems/ruby-2.3.0@hr-api/bin/ruby_executable_hooks:15:in `<main>'
--ruby2_out: protoc-gen-ruby2: Plugin failed with status code 1.

Would really like some direction on where/what to try next, as I'm stuck in a situation where I must have proto2 support, because my sender can't support proto3. Thanks.

@ebenoist
Copy link
Author

ebenoist commented Mar 15, 2017

@brianvh I ended up creating a new binstub that looks like this: https://gist.github.com/ebenoist/e72e3172fcdd22897ada7468e3262080

from a patch of the gem I created like this:
https://gist.github.com/ebenoist/7e9de05de51f0690cf18db91e2b8ccda

And then I invoke the proto 3 compiler like so:

protoc -I schemas/ --plugin=./bin/protoc-gen-ruby2 --ruby2_out=./out/ def/foo.proto

Works well enough for me until the remaining issues with proto3's official ruby gem are worked out.

@brianvh
Copy link

brianvh commented Mar 20, 2017

@ebenoist Thanks for the pointers. Unfortunately, your solution isn't working for me. I've tried multiple combinations of trying to match what you've done, but I'm getting hung up on this line in your custom binstub:

load Gem.bin_path("protobuf", "protoc-gen-ruby2")

When trying to execute on that, I'm being told:

/Users/brianvh/.rvm/gems/ruby-2.3.0@global/gems/bundler-1.11.2/lib/bundler/rubygems_integration.rb:355:in `block in replace_bin_path': can't find executable protoc-gen-ruby2 (Gem::Exception)
	from /Users/brianvh/.rvm/gems/ruby-2.3.0@hr-api/bin/protoc-gen-ruby2:17:in `<main>'
--ruby2_out: protoc-gen-ruby2: Plugin failed with status code 1.

If I try to go all the way to using your --plugin style, I get an even more spectacular error output, that amounts to largely the same error.

From all the pieces I've been trying to put together, it looks like there are two protoc-gen-ruby2 binary files that I need. However, beyond the binstub version you provided, as one, I don't know where I get the second binary, or where it goes. Any chance you can point me in the right direction?

@ebenoist
Copy link
Author

ebenoist commented Apr 3, 2017

@brianvh you'll need to make sure both of those binstubs are in your $PATH

[~]❥ which protoc-gen-ruby2
/Users/ebenoist/.rbenv/shims/protoc-gen-ruby2

@liveh2o
Copy link
Contributor

liveh2o commented Feb 22, 2018

This was resolved by #382, and released in v3.8.2.

@liveh2o liveh2o closed this as completed Feb 22, 2018
@ebenoist
Copy link
Author

@liveh2o awesome! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants