Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

Pathname#readlink

() -> untyped
readlink → new_pathname

Returns a new pathname containing the path stored in the symbolic link entry at the path stored in self:

Example
file_pn = Pathname('doc/maintainers.md')
link_pn = Pathname('/tmp/link')
link_pn.make_symlink(file_pn)
link_pn.readlink # => #<Pathname:doc/maintainers.md>
link_pn.delete   # Clean up.

Raises Errno::EINVAL if the path in self is not the path to a symbolic link.

See also #readlines #realdirpath #readable_real? #realpath also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0