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

FileUtils#rm

rm(list, force: nil, noop: nil, verbose: nil)

Remove file(s) specified in list. This method cannot remove directories. All StandardErrors are ignored when the :force option is set.

Example
FileUtils.rm %w( junk.txt dust.txt )
FileUtils.rm Dir.glob('*.so')
FileUtils.rm 'NotExistFile', force: true   # never raises exception
See also .rm #remove_file #rmdir #remove_entry_secure also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0