Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

File::Stat#symlink?

stat.symlink? → true or false

Returns true if stat is a symbolic link, false if it isn’t or if the operating system doesn’t support this feature. As File::stat automatically follows symbolic links, symlink? will always be false for an object returned by File::stat.

Example
File.symlink("testfile", "alink")   #=> 0
File.stat("alink").symlink?         #=> false
File.lstat("alink").symlink?        #=> true
See also #sticky? #uid #socket? #world_readable? also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0