Require paths with .. in them are not normalized #575

charliesome opened this Issue Mar 11, 2013 · 1 comment


None yet

2 participants


This requires 3 files to reproduce:


require "./b"


require "#{__FILE__}/../c"


puts "ok"

In Ruby 1.9 and 2.0, running a.rb prints "ok" to the terminal:

$ ruby a.rb

In JRuby, I get a LoadError instead:

$ ruby a.rb
LoadError: no such file to load -- /Users/charlie/crap/jruby-bug/./b.rb/../c
  require at org/jruby/
  require at /Users/charlie/.rubies/jruby-1.7.3/lib/ruby/shared/rubygems/custom_require.rb:36
   (root) at /Users/charlie/crap/jruby-bug/./b.rb:1
  require at org/jruby/
   (root) at /Users/charlie/.rubies/jruby-1.7.3/lib/ruby/shared/rubygems/custom_require.rb:1
   (root) at a.rb:1
headius commented Mar 14, 2013

It seems to be an issue with b.rb getting FILE as "./b.rb", which then doesn't canonicalize right with the .. in there. If you run b.rb directly or require it from a.rb without using ./, it works ok.

I'm looking into why we're presenting FILE as the relative version; it should be the canonical path, I believe.

@headius headius added a commit that closed this issue Mar 14, 2013
@headius headius Fix relative path logic for ./ and .. files.
* Loading a file starting with ./ now replaces ./ with cwd.
* Loading a file that contains any embedded .. will canonicalize
  before checking for file existance, since File#isFile will not
  handle those .. properly.
* Canonicalize both such paths for __FILE__

Fixes #575.
@headius headius closed this in 8a626e1 Mar 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment