Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

class method

File.unlink

(*::string | ::_ToPath file_name) -> ::Integer
File.delete(file_name, ...) → integer
File.unlink(file_name, ...) → integer

Deletes the named files, returning the number of names passed as arguments. Raises an exception on any error. Since the underlying implementation relies on the unlink(2) system call, the type of exception raised depends on its error type (see linux.die.net/man/2/unlink) and has the form of e.g. Errno::ENOENT.

See also Dir::rmdir.

See also .umask .utime .truncate .world_readable? also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0