JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-4220

File.dirname(__FILE__) doesn't return correct value when a script is loaded from classpath

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.5
    • Fix Version/s: JRuby 1.7.0.pre1
    • Component/s: Embedding
    • Labels:
      None
    • Number of attachments :
      0

      Description

      When a script is loaded from classpath, File.dirname(_FILE_) returns the base directory. Because of this behavior, test_dir.rb test_file.rb test_io.rb, and test_load_class_before_rb.rb fail. For example, test_io.rb outputs:

      [junit] [test_io.rb]
          [junit] Loaded suite -
          [junit] Started
          [junit] test_io.rb:71 warning: syswrite for buffered IO
          [junit] .........F...................
          [junit] Finished in 0.435 seconds.
          [junit] 
          [junit]   1) Failure:
          [junit] test_io_reopen(TestIO) [test_io.rb:450]:
          [junit] <"foo"> expected but was
          [junit] <"Error opening script file: /Users/yoko/DevSpace/jruby~main/./quiet.rb (No such file or directory)">.
          [junit] 
          [junit] 29 tests, 108 assertions, 1 failures, 0 errors
      

      All of those test scripts work well without errors when those are read from absolute path.

        Activity

        Hide
        Hiro Asari added a comment -

        This seems to be fixed on master.

        Show
        Hiro Asari added a comment - This seems to be fixed on master.

          People

          • Assignee:
            Unassigned
            Reporter:
            Yoko Harada
          • Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: