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
pathname_builtin.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/pathname_builtin.rb, line 1906
def lstat() File.lstat(@path) end
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.