Skip to content

reporting a better error when tmp doesn't work for temporary executables #5900

@jacaetevha

Description

@jacaetevha

Environment

  • JRuby version: 9.2.8.0
  • OS: Linux vpna-dev-tmc039.ad-dev.issgovernance.com 3.10.0-1062.1.1.el7.x86_64 #1 SMP Tue Aug 13 18:39:59 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Expected Behavior

When packing up a JRuby application as an executable JAR via warble, the app may crash if the temp directory (/tmp by default on most *nix systems) is mounted as read-only or noexec. A useful error message that instructs the user to set a temp directory to some user-space would be helpful. E.g. /tmp is mounted as read-only or noexec. Some native extensions may not work properly. Try setting the "java.io.tmpdir" variable to a directory that is writeable and executable by your process, if you run into errors with native extensions.

Example Application

example/bin/example

require 'irb'
IRB.start(__FILE__)

config/warble.rb

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

Actual Behavior

When /tmp is mounted as noexec an error similar to the following is written to the console:

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 -Djruby.native.verbose=true to java, you'll get more information that indicates that /tmp may be the problem (e.g. this gist).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions