Skip to content
Jason R. Clark edited this page Jun 17, 2018 · 2 revisions

Common Packaging Issues

I can't rely on the packaged app's working directory. What's up?

There isn't a consistent place for us to point the working directory on startup with packages, especially cross-OS. The reason is that the spot we should point is where your Ruby code lives... but that isn't actually in a normal directory. It's embedded inside of a JAR file that JRuby knows how to work inside of. Even where that JAR is placed differs from Mac to Windows to Linux, so there's no one place we can point at startup that would be the same across apps.

Most often people care about the working directory because of accessing other files relative to their source code. If that's the case, the File APIs in JRuby should work if you refer to things via relative paths like:

# From some Ruby file in your project
file_to_read = File.read(File.join(__FILE__, "../other/file.rb"))

More discussion

Common Error Messages

Platform Error message Solution
"Net::HTTPServerException: 404 "Not Found" when packaging app upgrade to JDK >= 1.7.0
OS X "LSOpenURLsWithRole() failed with error -10810" when loading app chmod +x pkg/[app_name].app/Contents/MacOS/JavaAppLauncher
OS X WARNING: Display must be created on main thread due to Cocoa restrictions. LoadError: Couldn't load backend Shoes::Swt'. Error: load error: shoes/swt -- org.eclipse.swt.SWTException: Invalid thread access org/jruby/RubyKernel.java:1054:in `require'" pass the -XstartOnFirstThread argument. for example: java -XstartOnFirstThread -jar pkg/window.jar