Created attachment 488364 [details] Sample Ruby script Description of problem: With JRuby 1.6.0 we have now experimental support for C extensions. Unfortunately guestfs doesn't work. To start work with JRuby and libguestfs do: 1. Download latest JRuby (http://www.jruby.org/) 2. Copy Ruby bindings from your Fedora 14 installation: cp /usr/lib/ruby/site_ruby/1.8/guestfs.rb $JRUBY_HOME/lib/ruby/site_ruby/1.8/ cp /usr/lib64/ruby/site_ruby/1.8/x86_64-linux/_guestfs.so $JRUBY_HOME/lib/native/x86_64-Linux/ 3. Launch irb: [goldmann@work tmp]$ jruby -J-Xmx1024m -I$JRUBY_HOME/lib/native/x86_64-Linux/ -S irb irb(main):001:0> require 'guestfs' => true irb(main):002:0> g = Guestfs::create => #<Guestfs::Guestfs:0x3458213c> irb(main):003:0> g.set_trace(1) Fatal: unknown type 0x22 from (irb):3:in `evaluate' from org/jruby/RubyKernel.java:1087:in `eval' from /home/goldmann/boxgrinder-torquebox/jruby/lib/ruby/1.8/irb.rb:158:in `eval_input' from /home/goldmann/boxgrinder-torquebox/jruby/lib/ruby/1.8/irb.rb:271:in `signal_status' from /home/goldmann/boxgrinder-torquebox/jruby/lib/ruby/1.8/irb.rb:155:in `eval_input' from org/jruby/RubyKernel.java:1417:in `loop' from org/jruby/RubyKernel.java:1190:in `catch' from /home/goldmann/boxgrinder-torquebox/jruby/lib/ruby/1.8/irb.rb:154:in `eval_input' from /home/goldmann/boxgrinder-torquebox/jruby/lib/ruby/1.8/irb.rb:71:in `start' from org/jruby/RubyKernel.java:1190:in `catch' from /home/goldmann/boxgrinder-torquebox/jruby/lib/ruby/1.8/irb.rb:70:in `start' from /home/goldmann/boxgrinder-torquebox/jruby/bin/jirb:13:in `(root)' Version-Release number of selected component (if applicable): ruby-libguestfs-1.8.2-1.fc14.x86_64
Created attachment 488365 [details] Strace output for create_disk.rb
From reading about this, it seems that JRuby has some support for C extensions, but that it is known to be problematic. There seem to be two possible ways forward: (1) Use the actual Java libguestfs bindings instead. This seems to be the standard reply, eg: http://stackoverflow.com/questions/526205/jruby-windows-and-native-extensions-how-do-i-distinguish-them/526456#526456 (2) Ask upstream JRuby developers if there is anything we can do to make the Ruby extensions friendlier towards JRuby or the JVM.
Now we have jruby in Rawhide, we could actually test this and debug it ...
(In reply to comment #3) > Now we have jruby in Rawhide, we could actually test this and > debug it ... Yes, I'll try to reproduce it on Rawhide and get back to you with my results.
With latest jruby-1.6.2-2.fc16.noarch which is in Rawhide I got: $ jruby -J-Xmx1024m -I/usr/share/jruby/lib/native/ -S irb /usr/bin/build-classpath: error: Could not find jffi Java extension for this JVM /usr/bin/build-classpath: error: Could not find jruby-yecht Java extension for this JVM /usr/bin/build-classpath: error: Some specified jars were not found irb(main):001:0> require 'guestfs' LoadError: load error: _guestfs -- java.lang.NoClassDefFoundError: com/kenai/jffi/Library from org/jruby/RubyKernel.java:1038:in `require' from /usr/share/jruby/lib/ruby/site_ruby/1.8/guestfs.rb:18:in `(root)' from org/jruby/RubyKernel.java:1038:in `require' from /usr/share/jruby/lib/ruby/site_ruby/1.8/guestfs.rb:1:in `evaluate' from org/jruby/RubyKernel.java:1088:in `eval' from /usr/share/jruby/lib/ruby/1.8/irb.rb:158:in `eval_input' from /usr/share/jruby/lib/ruby/1.8/irb.rb:271:in `signal_status' from /usr/share/jruby/lib/ruby/1.8/irb.rb:155:in `eval_input' from org/jruby/RubyKernel.java:1419:in `loop' from org/jruby/RubyKernel.java:1191:in `catch' from /usr/share/jruby/lib/ruby/1.8/irb.rb:154:in `eval_input' from /usr/share/jruby/lib/ruby/1.8/irb.rb:71:in `start' from org/jruby/RubyKernel.java:1191:in `catch' from /usr/share/jruby/lib/ruby/1.8/irb.rb:70:in `start' from /usr/share/jruby/bin/jirb:13:in `(root)' irb(main):002:0> It seems that ffi lib couldn't be found and seems to be a JRuby packaging issue to me.
It works for me OK if you use the Java bindings via JRuby. I will attach a test program to demonstrate.
Created attachment 513884 [details] JRuby program The attached program has been tested with JRuby in Fedora Rawhide. Note that it also requires the very latest libguestfs (>= 1.11.20).
I think the recommended approach (for jruby) is to use the Java classes. I have checked that this works. If this is sufficient for you I would like to close this bug.
Rich, That's fine. When I'll have more info on this in the future, I'll add to this ticket. Feel free to close it.
Closing as per comment 9.