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
file.c
View on GitHub ↗
static VALUE
rb_file_executable_p(VALUE obj, VALUE fname)
{
return RBOOL(rb_eaccess(fname, X_OK) >= 0);
}
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.