Skip to content

When inside a .JAR, __FILE__ returns a URI-like string that isn't understood by some keywords #1100

@mauricioszabo

Description

@mauricioszabo

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:

jar:file:/tmp/Directory%20with%20spaces/my-program.jar!/my-program/lib/boot.rb

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.

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