I’m having a problem with File.expand_path(FILE) after a chdir.
Looks like a bug in Ruby to me. If someone can tell me what I’m doing
wrong, I’d be grateful.
Here’s the reduction:
[ryan@kursk 15:26:38 ~]$ cat tmp/demo-problem.rb
puts "starting working directory: " + Dir.getwd
puts "expand_path: " + File.expand_path(FILE)
puts "about to change to dirname of FILE: " + FILE
Dir.chdir(File.dirname(FILE))
puts "new working directory: " + Dir.getwd
puts "expand_path: " + File.expand_path(FILE)
[ryan@kursk 15:26:40 ~]$ cd tmp
[ryan@kursk 15:26:44 ~/tmp]$ ruby demo-problem.rb
starting working directory: /Users/ryan/tmp
expand_path: /Users/ryan/tmp/demo-problem.rb
about to change to dirname of FILE: demo-problem.rb
new working directory: /Users/ryan/tmp
expand_path: /Users/ryan/tmp/demo-problem.rb
[ryan@kursk 15:26:45 ~/tmp]$ cd …
[ryan@kursk 15:26:50 ~]$ ruby tmp/demo-problem.rb
starting working directory: /Users/ryan
expand_path: /Users/ryan/tmp/demo-problem.rb
about to change to dirname of FILE: tmp/demo-problem.rb
new working directory: /Users/ryan/tmp
expand_path: /Users/ryan/tmp/tmp/demo-problem.rb
[ryan@kursk 15:26:56 ~]$
···
–
Ryan “John” Platte
Custom services, NIKA Consulting
http://nikaconsulting.com/