Skip to content

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

instance method

Pathname#mkdir

(?::Integer perm) -> ::Integer
mkdir(permissions = 0755) → 0

Creates a directory in the underlying file system at the path in self, with the given permissions; see File Permissions:

Example
Dir.mkdir('foo')
File.stat(Dir.new('foo')).mode.to_s(8) # => "40775"
Dir.mkdir('bar', 0644)
File.stat(Dir.new('bar')).mode.to_s(8) # => "40644"
Dir.rmdir('foo')
Dir.rmdir('bar')

Argument permissions is ignored on Windows.

See also #make_symlink #mkpath #make_link #mountpoint? also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0