I'm facing a strange problem when I'm using JRuby + Warbler: I'm packing a JRuby program inside a .jar file. But when the path that the JAR is contains spaces, File.dirname(__FILE__) returns some kind of URI to the file like the following:
These "%20" confuses some commands like require_relative (it don't work at all), or File.read[lines] (don't work either). Somehow, require works fine.
A workaround that I did is to create a URI.unescape(File.dirname(__FILE__)), but I don't know if this can lead to problems if, for instance, the file that I'm trying to read has %20 on its filename.
Yeah, not all methods in the system recognize URLs. It's a standing task to unify file-aware methods to know about URLs, and we've been adding support a piece at a time.
So, summarizing this issue:
When I tried to debug this issue, require_relative and File.read had become confused with these %20 (the URI representation of space). When I remove them and substitute with spaces, everything works fine. Maybe there is a way to expose to JRuby the URI without these %20, so there would be no need to change code on require_relative or File.read.
'require' also has this error when the gem is packaged in jar as resource when using jruby 1.7.8.
Changing to some path that doesn't have space solves the problem.
Here is part of stacktrace:
LoadError: no such file to load -- jar:file:C:/Documents%20and%20Settings/works/.m2/repository/some-folder/oss/compass-maven-plugin/0.0.1/compass-maven-plugin-0.0.1.jar!/gems/sass-3.2.12/lib/sass/../sass
require at org/jruby/RubyKernel.java:1084
require at file:/C:/Documents and Settings/works/.m2/repository/org/jruby/jruby-complete/1.7.8/jruby-complete-1.7.8.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:55
I've tried to reproduce the issue in ubuntu, but it seems to work:
$ bin/jruby -e 'require "jar:file:/tmp/dir with space/test.jar!/foo/test.rb"'
File: file:/tmp/dir with space/test.jar!/foo/test.rb, dirname: "file:/tmp/dir with space/test.jar!/foo"
I'll try to verify it with windows system as well, but could any if you guys make sure that there is still an issue with recently released 1.7.11 release? You can download the jar I used here: https://drive.google.com/file/d/0B3EcYC59OaVjN21mTm92UVFnX0k/edit?usp=sharing
I think it is working right now, so we can close this issue.