Skip to content

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

instance method

FileTest#executable?

(::path file_name) -> bool
File.executable?(path) → true or false

Returns whether the filesystem entry at the given path is executable by the effective owner/group of the current process:

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

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 #empty? #executable_real? #directory? #exist? also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0