Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

class method

Dir.unlink

(::path dirname) -> 0
Dir.delete(dirpath) → 0
Dir.rmdir(dirpath) → 0
Dir.unlink(dirpath) → 0

Removes the directory entry (hard link) at dirpath, along with its associated inode:

Example
dirpath = '/tmp/tmpdir'
Dir.mkdir(dirpath)
Dir.rmdir(dirpath) # => 0

Raises an exception if the directory is not empty.

See also .tmpdir #chdir .scan #children also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0