Skip to content

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

instance method

File::Stat#executable?

() -> bool
executable? → true or false

Returns whether the filesystem entry represented by self is executable by the effective owner/group of the current process:

Example
File.stat('/bin/ruby').executable?   # => true
File.stat('/etc').executable?        # => true
File.stat('/etc/passwd').executable? # => false

Raises Errno::ENOENT if the entry does not exist.

Note that some filesystem settings may cause this method to return true even though the entry is not executable by the effective owner/group.

See also #directory? #executable_real? #dev_minor #file? also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0