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#lstat

() -> ::File::Stat
lstat → stat

Returns a new File::Stat object for the entry at the path in self. Unlike Pathname#stat, does not follow symbolic links; therefore the returned object contains information for that entry, regardless of whether it is a symbolic link:

Example
file_pn = Pathname('/etc/passwd')
link_pn = Pathname('/tmp/foo')
link_pn.make_symlink(file_pn)
# Method lstat does not follow the symlink, so the birthtimes are different.
file_pn.lstat.birthtime # => 2025-06-10 11:10:47.358999941 -0500
link_pn.lstat.birthtime # => 2026-09-23 14:12:00.978946471 -0500
# Method stat follows the symlink, so the birthtimes are the same.
file_pn.stat.birthtime  # => 2025-06-10 11:10:47.358999941 -0500
link_pn.stat.birthtime  # => 2025-06-10 11:10:47.358999941 -0500
link_pn.delete          # Clean up.
See also #lchown #lutime #lchmod #make_link also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0