Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

class method

File.realpath

File.realpath(pathname [, dir_string]) → real_pathname

Returns the real (absolute) pathname of pathname in the actual filesystem not containing symlinks or useless dots.

If dir_string is given, it is used as a base directory for interpreting relative pathname instead of the current directory.

All components of the pathname must exist when this method is called.

See also .realdirpath .rename .readlink .setgid? also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0