Ricardo,
Monkeybars apps are distributed as a jar-only package. We have
workarounds for all of these issues.
On Apr 2, 2009, at 4:09 AM, Ricardo T. wrote:
Hi,
We did a recent effort to run from a Jar. We used a patch to
require from Peter Chan, which made things a bit easier. While it
goes much further with less patching to rails, there are still three
main issues that are failing:
- File.directory? fails inside jars - During Rails
initialization, this is frequently done “if File.directory?(dir)”,
so the initialization procedure has to be patched because of this
http://jira.codehaus.org/browse/JRUBY-2289 reports exactly what you’re
saying.
Here’s a sample from the Monkeybars code to find directories in a glob:
Dir.glob(File.expand_path(File.dirname(FILE) + “/**/*”)).each do |
directory|
File.directory? is broken in current JRuby for dirs inside jars
$LOAD_PATH << directory unless directory =~ /.\w+$/
end
So it’s basically treating extensionless files as directories. It’s
not perfect but that’s the best workaround we have right now.
- Directory globbing fails inside jars - There are several places
where dir globbing is used, such as launching initializers
http://jira.codehaus.org/browse/JRUBY-2518
A Ruby-based fix is sitting in there. It doesn’t work for all kinds of
globs, but it worked for our case.
- LOADPATH doesn’t seem to be respected when running from a jar.
This is the worst problem of all, since it makes loading the
frameworks require a lot of patching.
$LOAD_PATH is respected, but has a lot of quirks. For one, your jar is
essentially treated as a dir, so you need to step out of the jar if
you need something outside of it with another.
Jar paths have file:// in the front, and myjar.jar!/inside_jar_dir
somewhere after that. If you’re stepping outside a jar, you’ll need to
remove the file://. The same works for reaching inside a jar.
Also, if you have requireable files of the same name sitting next to
your jar (foo.rb and myapp.jar!/foo.rb), JRuby will typically load
foo.rb. I think this is a load path quirk (the dir ‘.’ is on the load
path). We’ve gotten around this by clearing the load path on app start
and then rebuilding it. This also kept us from having gems that were a
part of our system get loaded even if the app didn’t have them - which
would then fail when giving the app to some other machine without
those gems. We have some documentation on this here:
http://kenai.com/projects/monkeybars/pages/UseRubyGemsInYourApplication
I wrote this mainly for future reference, but if anyone has fixed
any of these issues, I’d be interested to know about it. best
regards,
Ricardo T.
Another bugs you might be interested in:
http://jira.codehaus.org/browse/JRUBY-3499 - URL encoding problems
with jar paths (such as encoding spaces, but not reading the encoding
properly).
The bug says 3499 (the line above) is unresolved, but I think it’s
fixed now.
Hope that helps!
Logan B.
[email protected]
http://www.logustus.com
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email