Search code examples
rubymongodbjruby

Jruby - cannot install Mongo gem


JRuby 9.1.12.0 (2.3.3) Rubygem 2.6.11 Win 7 Mongo 2.3.2 Bson-4.2.2

I have moved over to JRuby to enable me to use some Java based libraries and I have managed to install all of my original gems cucumber/Rspec/Watir etc but I cannot seem to install the Mongo Gem. I get the following error message:

C:\Ruby\gem>jruby -S gem install mongo
Building native extensions. This could take a while...
C:/jruby-9.1.12.0/lib/ruby/stdlib/rubygems/ext/ext_conf_builder.rb:58:  warning: Tempfile#unlink or delete called on open file
; ignoring
ERROR:  Error installing mongo:
ERROR: Failed to build gem native extension.

current directory: C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/bson-4.2.2/ext/bson
C:/jruby-9.1.12.0/bin/jruby.exe -r ./siteconf20170719-4116-mhpj6s.rb extconf.rb
creating Makefile

current directory:  C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/bson-4.2.2/ext/bson
make "DESTDIR=" clean

current directory:   C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/bson-4.2.2/ext/bson
make "DESTDIR="
make: *** No rule to make target    `C:/jruby-9.1.12.0/lib/ruby/include/ruby/ruby.h', needed by `bson_native.o'.       Stop.

make failed, exit code 2

Gem files will remain installed in   C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/bson-4.2.2 for inspection.
Results logged to    C:/jruby-9.1.12.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.3.0/bson-4.2.2/gem_make.out

Solution

  • this should work, maybe do a clean bundle install ... so that you install the latest gems :

    $ jruby -S gem install mongo
    Fetching: bson-4.2.2-java.gem (100%)
    Successfully installed bson-4.2.2-java
    Fetching: mongo-2.4.2.gem (100%)
    Successfully installed mongo-2.4.2
    2 gems installed
    

    #

    $ jruby -v
    jruby 9.1.8.0 (2.3.1) 2017-03-06 90fc7ab Java HotSpot(TM) 64-Bit Server VM 25.121-b13 on 1.8.0_121-b13 +jit [linux-x86_64]