Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Pathname#realdirpath
(?::string | ::Pathname base_dir) -> ::Pathname
realdirpath → new_pathname
pathname_builtin.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/pathname_builtin.rb, line 2259
def realdirpath(...) self.class.new(File.realdirpath(@path, ...)) end
Returns a new pathname containing the real (absolute) pathname of the path in self; the new path is the path in the actual filesystem, and does not contain useless dot-entries ('.' or '..') or symbolic links:
Example
Pathname('/etc/./passwd/../../var').realdirpath # => #<Pathname:/var>
Only the last component of the new path may be nonexistent:
Example
Pathname('/etc/./passwd/../../var/nosuch').realdirpath # => #<Pathname:/var/nosuch> Pathname('/etc/./passwd/../../var/nosuch/nosuch').realdirpath # Raises Errno::ENOENT: No such file or directory.
Method realpath is similar, but requires all components to exist.