Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

FileUtils.remove

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

Alias of .rm

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 .pwd .remove_dir also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1