You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a CLI gem called myapp that uses a C shared library (some_lib.so) which is interfaced with ruby code using ffi gem. The library is loaded in a Ruby module using:
This works in development but not when the gem is packaged with warbler into a "runnable" jar file. I've tried various paths but it either resolves to the host system path which won't work on another system or errors out with file loaderror, cannot open library 'uri:classloader://myapp/path/to/some_lib.so'.
I verified the library some_lib.so is packaged into the jar file under the correct subfolders myapp/ext/some_lib.so along with the rest of the gem files in their respective folders.
It seems like it is not finding the library within the internal packaged files. Do you have any thoughts on what's going on and how I can get ffi_lib to load the file that is packaged in the jar file?
Error backtrace:
USHQ0000:projects hm$ java -jar myapp.jar t
# These resolve to host system file paths which won't work on another system# puts "Dirwd: #{Dir.getwd}"# puts "Dirpwd: #{Dir.pwd}"# puts "Dir: #{__dir__}"# puts "File: #{__FILE__}"# puts "File_exp: #{File.expand_path(__FILE__)}"
Dirpwd: /Users/hm/Documents/projects
Dir: /Users/hm/Documents/projects/myapp/lib/myapp
File: /Users/hm/Documents/projects/myapp/lib/myapp/some_lib.rb
File_exp: /Users/hm/Documents/projects/myapp/lib/myapp/some_lib.rb
# puts ENV["GEM_HOME"]# puts ENV["BUNDLE_GEMFILE"] # This seems like an internal path within the jar file... correct?
uri:classloader:/
uri:classloader://myapp/Gemfile
LoadError: Could not open library 'uri:classloader://myapp/ext/some_lib.so': dlopen(uri:classloader://myapp/ext/some_lib.so, 5): image not found
ffi_lib at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/ffi/library.rb:114
map at org/jruby/RubyArray.java:2588
ffi_lib at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/ffi/library.rb:84
<module:XenaSflm> at /Users/hm/Documents/projects/myapp/lib/myapp/some_lib.rb:28
<module:Dnatools> at /Users/hm/Documents/projects/myapp/lib/myapp/some_lib.rb:6
<main> at /Users/hm/Documents/projects/myapp/lib/myapp/some_lib.rb:5
require at org/jruby/RubyKernel.java:974
require_relative at org/jruby/RubyKernel.java:1002
<main> at /Users/hm/Documents/projects/myapp/lib/myapp/sflm.rb:3
require at org/jruby/RubyKernel.java:974
require_relative at org/jruby/RubyKernel.java:1002
<main> at /Users/hm/Documents/projects/myapp/lib/myapp.rb:30
require at org/jruby/RubyKernel.java:974
require_relative at org/jruby/RubyKernel.java:1002
<main> at myapp/bin/myapp:5
load at org/jruby/RubyKernel.java:1009
<main> at uri:classloader:/META-INF/main.rb:1
require at org/jruby/RubyKernel.java:974
require at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:83
<main> at <script>:3
ERROR: org.jruby.embed.EvalFailedException: (LoadError) Could not open library 'uri:classloader://myapp/ext/some_lib.so': dlopen(uri:classloader://myapp/ext/some_lib.so, 5): image not found
The text was updated successfully, but these errors were encountered:
I have a CLI gem called
myapp
that uses a C shared library (some_lib.so
) which is interfaced with ruby code usingffi
gem. The library is loaded in a Ruby module using:This works in development but not when the gem is packaged with warbler into a "runnable"
jar
file. I've tried various paths but it either resolves to the host system path which won't work on another system or errors out withfile loaderror, cannot open library 'uri:classloader://myapp/path/to/some_lib.so'
.I verified the library
some_lib.so
is packaged into the jar file under the correct subfoldersmyapp/ext/some_lib.so
along with the rest of the gem files in their respective folders.It seems like it is not finding the library within the internal packaged files. Do you have any thoughts on what's going on and how I can get
ffi_lib
to load the file that is packaged in the jar file?Error backtrace:
The text was updated successfully, but these errors were encountered: