Skip to content

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

class method

Dir.mkdir

Dir.mkdir( string [, integer] ) → 0

Makes a new directory named by string, with permissions specified by the optional parameter anInteger. The permissions may be modified by the value of File::umask, and are ignored on NT. Raises a SystemCallError if the directory cannot be created. See also the discussion of permissions in the class documentation for File.

Example
Dir.mkdir(File.join(Dir.home, ".foo"), 0700) #=> 0
See also .home .mktmpdir .glob .new also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0