History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: JRUBY-2366
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Thomas E Enebo
Reporter: Logan Barnett
Votes: 0
Watchers: 4
Operations

If you were logged in you would be able to see more operations.
JRuby

File.expand_path doesn't work under Java Web Start deployments

Created: 06/Apr/08 04:43 PM   Updated: Yesterday 03:00 AM
Component/s: Core Classes/Modules
Affects Version/s: JRuby 1.1RC3
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments: 1. File example_code_for_jnlp_expandpath_issue.tgz (8 kb)

Environment: Windows XP


 Description  « Hide
Inside src/manifest.rb
puts "this file: #{File.expand_path(File.dirname(__FILE__))}"

Windows:
C:/Documents and Settings/Administrator/http:/www.happycamperstudios.com/monkeybars/copy-center/CopyCenter.jar!/src

OSX:
file:/Users/logan/Library/Caches/Java/cache/javaws/http/Dwww.happycamperstudios.com/P80/DMmonkeybars/DMcopy-center/RMCopyCenter.jar!/src

This seems to work ok for a Mac.
Doing require 'foo' at this point causes issues.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Logan Barnett - 19/Apr/08 05:46 PM
Here's some more info that might help.

When active_support is required:
no such file to load – http://www.happycamperstudios.com/monkeybars/copy-center/CopyCenter.jar!/lib/ruby/active_support/inflections

Active support requires inflections like so:
require 'active_support/inflector'

Active support sits in the lib/ruby directory, which gets packed into the jar.

Relevant Load Path:
C:/Documents and Settings/Administrator/http:/www.happycamperstudios.com/monkeybars/copy-center/CopyCenter.jar!/lib/ruby


James Britt - 13/Jun/08 05:56 PM
This is a slightly contrived but functional example showing that a call to File.expand_path breaks when an app is deployed via JRuby.

Main.java is in place so that there is a Java class to kick things off.

It evals some Ruby code to load main.rb, which would typically hold the start of the app logic.

main.rb tries to require another Ruby file, code.rb (both files are in the src/ directory).

The require call fails because it is using File.expand_path.

Main.rb also has some (commented) code that alters File.expand_path to look for and remove paths that contain an http://... string. It seems to work well enough (though feels hacky).

There is also a jnlp file that you will need to adjust for the correct URL.

james.britt@gmail.com if you have questions.


Charles Oliver Nutter - 03/Jul/08 06:39 PM
Since you updated fairly recently, I presume this bug is still affecting you, yes?

Logan Barnett - 18/Jul/08 03:00 AM
Charlie,
Sorry for taking so long to get back to you.

I just updated to the newest version, and the problem seems to effect OSX now. Minutes before the same web start app was running for me. At least it's consistent across platforms now (:

In short, yep, we're still affected.

I do have a workaround (which complements James's workaround, depending on what's needed).
If you can avoid File.expand_path, you can add the directories needed onto your load path by hand ($LOAD_PATH << 'foo'), and then require your file without any directory information (require 'bar'). I'll have to see if I can do a Dir.glob without expand path, as it would really help me along.