Skip to content

File.whereis

Daniel Berger edited this page Aug 22, 2018 · 1 revision

File.whereis(program, path=ENV['PATH'])

Returns an array of each program within path, or nil if it cannot be found.

On MS Windows, it looks for executables ending with the suffixes defined in your PATHEXT environment variable, or '.exe', '.bat' and '.com' if that isn't defined, which you may optionally include in the program argument.

Examples:

  File.whereis('ruby') # => ['/usr/bin/ruby', '/usr/local/bin/ruby']
  File.whereis('foo')  # => nil
Clone this wiki locally