I'm running Ruby on Windows though I don't know if that should make a difference. All I want to do is get the current working directory's absolute path. Is this possible from irb? Apparently from a script it's possible using File.expand_path(__FILE__)
But from irb I tried the following and got a "Permission denied" error:
File.new(Dir.new(".").path).expand
Dir.pwd
) or do you want the directory where the currently running script is located (which isFile.dirname(__FILE__)
)? Imagine calling a script from anywhere else (likeruby testdirectory/testscript.rb
) here, the two will be different! – EufemiaeugenFile.expand_path(__FILE__)
" - because__FILE__
's location is a different animal than current working dir (which isDir.pwd
). – EufemiaeugenFile.expand_path(__FILE__)
does not "get the current working directory's absolute path". – Recess