Skip to content
This repository has been archived by the owner on May 28, 2019. It is now read-only.

jruby gem can't be loaded #30

Closed
aslakhellesoy opened this issue Feb 14, 2013 · 4 comments
Closed

jruby gem can't be loaded #30

aslakhellesoy opened this issue Feb 14, 2013 · 4 comments
Labels

Comments

@aslakhellesoy
Copy link
Contributor

Reproduce:

rvm jruby
gem install bool && ruby -e "require 'bool'"

Output:

Successfully installed bool-1.0.10-java
1 gem installed
LoadError: no such file to load -- libbool
    require at org/jruby/RubyKernel.java:1027
    require at /home/aslak/.rvm/rubies/jruby-1.7.2/lib/ruby/shared/rubygems/custom_require.rb:36
  Evaluator at /home/aslak/.rvm/gems/jruby-1.7.2/gems/bool-1.0.10-java/lib/bool/evaluator.rb:4
       Bool at /home/aslak/.rvm/gems/jruby-1.7.2/gems/bool-1.0.10-java/lib/bool/evaluator.rb:2
     (root) at /home/aslak/.rvm/gems/jruby-1.7.2/gems/bool-1.0.10-java/lib/bool/evaluator.rb:1
    require at org/jruby/RubyKernel.java:1027
     (root) at /home/aslak/.rvm/rubies/jruby-1.7.2/lib/ruby/shared/rubygems/custom_require.rb:1
    require at /home/aslak/.rvm/rubies/jruby-1.7.2/lib/ruby/shared/rubygems/custom_require.rb:36
    require at org/jruby/RubyKernel.java:1027
     (root) at /home/aslak/.rvm/gems/jruby-1.7.2/gems/bool-1.0.10-java/lib/bool.rb:5
     (root) at -e:1

Any takers? If someone fixes it, please do it on a branch so it can be reviewed.

@aslakhellesoy
Copy link
Contributor Author

Looks like require('libbool') in evaluator.rb should be require('bool_ext').

What I don't understand is why this doesn't raise an exception when the specs are run on jruby. Changing it to require('libfoo') does cause an exception to be raised, so I'm wondering how require('libbool') can possibly pass at all in development?!?!

I'd like to understand this before going ahead and replacing it with the correct require('bool_ext).

FWIW, require('bool_ext) would load bool_ext.jar under lib, which is just a copy of the jar built by the /java project (see ruby/Rakefile and java/pom.xml).

@mattwynne
Copy link
Contributor

On 14 Feb 2013, at 14:18, Aslak Hellesøy notifications@github.com wrote:

I'm wondering how require('libbool') can possibly pass at all in development?!?

What was it that caused you to think it would be libbool in the first place? Maybe the JVM is thinking along the same lines... :)

@aslakhellesoy
Copy link
Contributor Author

The jar was once called libbool.jar. I renamed it and forgot to update the source.

Here is the super weird thing:
Try changing it to require 'libwtf' and see rake fail. Then add a lib/wtf.rb file and see it pass (!!?!!). Wat?

This sort of explains why require 'libbool' works (there is a lib/bool.rb). If you move the require 'libwtf' to the top of the file and run with MRI it fails as expected. It seems like this weird loading is a JRuby thing.

It would be nice to have a minimal simple example we could send to the JRuby people and ask why it works this way. The strange thing is that it doesn't seem to work like this when using the gem - only when running the specs in "dev".

I'd like to fully understand this before fixing it.

@aslakhellesoy
Copy link
Contributor Author

I reproduced it: https://github.com/aslakhellesoy/jruby-require-wat

Now that I'm confident this is a JRuby bug we can fix this.

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

No branches or pull requests

2 participants