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

hutch installs bunny but complains about missing march_hare on jruby #368

Open
klobuczek opened this issue Aug 25, 2021 · 5 comments
Open

Comments

@klobuczek
Copy link
Contributor

On jruby-9.2.19.0 gem install hutch installs bunny as dependency, but on loading complains about missing march_hare:

(base) ~/m/org-api ❯❯❯ rails c                                                                                                                                                                                                                                          
LoadError: no such file to load -- march_hare
                               require at org/jruby/RubyKernel.java:974
                               require at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34
                               require at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324
                       load_dependency at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:291
                               require at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324
                                <main> at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/hutch-1.1.0/lib/hutch/adapters/march_hare.rb:1
                               require at org/jruby/RubyKernel.java:974
                               require at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34
                               require at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324
                       load_dependency at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:291
                               require at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324
                                <main> at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/hutch-1.1.0/lib/hutch/adapter.rb:2
                               require at org/jruby/RubyKernel.java:974
                               require at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34
                               require at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324
                       load_dependency at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:291
                               require at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324
                                <main> at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/hutch-1.1.0/lib/hutch.rb:1
                               require at org/jruby/RubyKernel.java:974
                               require at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34
                               require at /Users/heinrich/.rvm/rubies/jruby-9.2.19.0/lib/ruby/gems/shared/gems/bundler-2.2.21/lib/bundler/runtime.rb:66
                                  each at org/jruby/RubyArray.java:1820
                               require at /Users/heinrich/.rvm/rubies/jruby-9.2.19.0/lib/ruby/gems/shared/gems/bundler-2.2.21/lib/bundler/runtime.rb:61
                                  each at org/jruby/RubyArray.java:1820
                               require at /Users/heinrich/.rvm/rubies/jruby-9.2.19.0/lib/ruby/gems/shared/gems/bundler-2.2.21/lib/bundler/runtime.rb:50
                               require at /Users/heinrich/.rvm/rubies/jruby-9.2.19.0/lib/ruby/gems/shared/gems/bundler-2.2.21/lib/bundler.rb:174
                                <main> at /Users/heinrich/mck/org-api/config/application.rb:30
                               require at org/jruby/RubyKernel.java:974
                  require_application! at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/railties-6.0.3.7/lib/rails/command/actions.rb:22
  require_application_and_environment! at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/railties-6.0.3.7/lib/rails/command/actions.rb:14
                               perform at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/railties-6.0.3.7/lib/rails/commands/console/console_command.rb:101
                                   run at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/thor-1.1.0/lib/thor/command.rb:27
                        invoke_command at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/thor-1.1.0/lib/thor/invocation.rb:127
                              dispatch at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/thor-1.1.0/lib/thor.rb:392
                               perform at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/railties-6.0.3.7/lib/rails/command/base.rb:69
                                invoke at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/railties-6.0.3.7/lib/rails/command.rb:46
                                <main> at /Users/heinrich/.rvm/gems/jruby-9.2.19.0/gems/railties-6.0.3.7/lib/rails/commands.rb:18
                               require at org/jruby/RubyKernel.java:974
                                <main> at bin/rails:6
@klobuczek
Copy link
Contributor Author

Ok, I think I figured it out. You do not provide hutch-java, but have conditional gemspec:

  if defined?(JRUBY_VERSION)
    gem.platform = 'java'
    gem.add_runtime_dependency 'march_hare', '>= 3.0.0'
  else
    gem.platform = Gem::Platform::RUBY
    gem.add_runtime_dependency 'bunny', '>= 2.16', '< 3.0'
  end

This condition is resolved at build time, not at install time. Consequently, you need to build and deploy the gem for both platforms ruby and java.
An alternative would be to not require bunny or march_hare and leave it to the user to include those, but since you have as well conditional code the former approach would be nicer.

@klobuczek
Copy link
Contributor Author

@michaelklishin could we tackle this to avoid bunny being pulled in on jruby. I can provide a PR but need from you a decision on how you want to handle this. Keep deploying separate jruby versions or remove both bunny and march_hare dependencies from the gem. Using the gem from source works because the gemspec is available, but there is no gemspec in deployed gems and hence the platform condition has been resolved to the platform on which the gem was built.

@michaelklishin
Copy link
Member

@klobuczek thank you for volunteering to provide a PR.

What do you mean by "keep deploying separate JRuby versions", that we would push the gem twice on two platforms? That'd be OK with me. Not depending on any libraries sounds like a usability disaster given the existing install base and relative project maturity.

@klobuczek
Copy link
Contributor Author

klobuczek commented Jan 11, 2023

@michaelklishin sorry, I totally dropped this topic.
Yes, one way would be to deploy to rubygems a generic version that would depend on bunny and a java-specific version depending on march_hare.
Another way would be to provide march_hare under the bunny name for java platform. That way you would not need 2 platform-dependent hutch versions, but would have 2 bunny flavors.

We have a similar problem with activegraph and neo4j-ruby-driver. We have chosen the latter and provided 2 completely different implementations under the same name neo4j-ruby-driver but we made the api of both implementations identical, something that you achieve first with the adapters in hutch. So unless you move the adapters to bunny and march_hare probably the 1st option might be easier for you.

@klobuczek
Copy link
Contributor Author

@michaelklishin
Could you deploy the -java version of the gem?
Simply run whatever you are doing usually e.g. rake release but in a jruby context. It will push to rubygems a version with the -java suffix.

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

2 participants