Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native JFFI library not found on Mac #2935

chrisseaton opened this issue May 13, 2015 · 2 comments

Native JFFI library not found on Mac #2935

chrisseaton opened this issue May 13, 2015 · 2 comments


Copy link

There something wrong with where JFFI is looking for its native library on the Mac in JRuby. We are getting the fallback version. You may not notice this in normal JRuby, as it's silently ignored, but in Truffle we require the native version and so we're seeing the error.

$ bin/jruby -X+T -e 'puts 14'
Truffle internal error: java.lang.RuntimeException: Error while calling the constructor of Truffle's RubyContext
java.lang.RuntimeException: Error while calling the constructor of Truffle's RubyContext
    at org.jruby.Ruby.loadTruffleContext(
    at org.jruby.Ruby.getTruffleContext(
    at org.jruby.Ruby.runInterpreter(
    at org.jruby.Ruby.runInterpreter(
    at org.jruby.Ruby.runNormally(
    at org.jruby.Ruby.runFromMain(
    at org.jruby.Main.doRunFromMain(
    at org.jruby.Main.internalRun(
    at org.jruby.Main.main(
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
    at java.lang.reflect.Constructor.newInstance(
    at org.jruby.Ruby.loadTruffleContext(
    ... 9 more
Caused by: java.lang.NoClassDefFoundError: Could not initialize class jnr.posix.POSIXFactory$DefaultLibCProvider$SingletonHolder
    at jnr.posix.POSIXFactory$DefaultLibCProvider.getLibC(
    at jnr.posix.BaseNativePOSIX.<init>(
    at jnr.posix.MacOSPOSIX.<init>(
    at jnr.posix.POSIXFactory.loadMacOSPOSIX(
    at jnr.posix.POSIXFactory.loadNativePOSIX(
    at jnr.posix.POSIXFactory.getNativePOSIX(
    at org.jruby.truffle.runtime.RubyContext.<init>(
    ... 14 more

The error is not actually NoClassDefFoundError - but a static initialiser in there is failing. If you attach a debugger you see whereabouts it's going wrong. It looks like it's looking for the wrong type of file.

Workaround: cp lib/jni/Darwin/libjffi-1.2.jnilib lib/jni/Darwin/libjffi-1.2.dylib

Copy link
Contributor Author

This was ok in pre2 - if you go back and modify Truffle to load POSIX as

posix = POSIXFactory.getNativePOSIX(new TrufflePOSIXHandler(this));

It works fine.

Copy link
Contributor Author

No longer a problem.

@enebo enebo added this to the Invalid or Duplicate milestone Feb 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants