reporting a better error when tmp doesn't work for temporary executables #5900
When packing up a JRuby application as an executable JAR via
require 'irb' IRB.start(__FILE__)
Warbler::Config.new do |config| config.features = %w(gemjar) config.includes = FileList["script.rb"] config.jar_extension = "jar" config.autodeploy_dir = "dist/" config.bytecode_version = "1.8" end
warble java -jar example.jar # throws an error if /tmp is noexec or read-only
NotImplementedError: fstat unimplemented unsupported or native support failed to load; see https://github.com/jruby/jruby/wiki/Native-Libraries initialize at org/jruby/RubyIO.java:1015 open at org/jruby/RubyIO.java:1156 initialize at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/irb/input-method.rb:141 initialize at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/irb/context.rb:70 initialize at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/irb.rb:410 start at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/irb.rb:381 <main> at dbconsole/bin/dbconsole:10 load at org/jruby/RubyKernel.java:1022 <main> at uri:classloader:/META-INF/main.rb:1 require at org/jruby/RubyKernel.java:987 <main> at uri:classloader:/META-INF/main.rb:1 <main> at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1 ERROR: org.jruby.embed.EvalFailedException: (NotImplementedError) fstat unimplemented unsupported or native support failed to load; see https://github.com/jruby/jruby/wiki/Native-Libraries
If you pass
The text was updated successfully, but these errors were encountered:
Read-only bug is at #1302. A suggestion there is that we could pick a different location, either by default or only when we detect that the default tmp location won't work.
However, it's not clear how we can tell tmp won't work unless we try to make it work. As it is, we are not the ones unpacking the native library; that is done by either jnr-ffi or jffi (I don't recall).
So we definitely need a better error or warning when tmp is unusable, and ideally a simple way to fall back to some other location (which is likely a change to the appropriate JNR library).
I have a patch for JFFI that will enhance the existing errors by indicating what failed and how to remedy it.
For read-only temp location, you'll see the following in
And for a noexec temp location, the error will be like this:
There's multiple levels of exception-handling and wrapping in this logic, unfortunately, so this message appears somewhat deep in a chain of exceptions...but it's a better error with a remedy.
That first error is off a bit...
< ... Unable to write jffi binary stub to `/nowrite`. Set `TMPDIR` or Java property `java.io.tmpdir` to a read/write path that is not mounted "noexec". > ... Unable to write jffi binary stub to `/nowrite`. Set `TMPDIR` or Java property `java.io.tmpdir` to a read/write path that is not mounted "readonly".
I think the original is right...the path needs to be readable and writable (implying it is not readonly) and must not be mounted "noexec" (which is not the same as +x, so I wasn't sure of a better way to say this in few words).
Note I'm using the same remedy for both since the first thing someone might see is a read-only temp and the second thing they might see is noexec, so in both errors the remedy is to set temp to a read-only, non-noexec path.
When the jffi stub library must be emitted to and loaded from a local filesystem, we may end up doing so with a path that is either read-only or "noexec". This change attempts to detect those cases and inform users about why the error happened and how to fix it. See jruby/jruby#5900.