简体   繁体   中英

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

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]

You're trying to use a MRI gem that depends on native extensions in JRuby - this isn't going to work (easily).

Your options are:

  1. find a pure-ruby mongo driver that doesn't depend on native extensions
  2. find a java mongodb driver that you can wrap in ruby code and load as a dependency in your jruby application

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM