Skip to content

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

class method

Dir.home

(?::string? user) -> ::String
Dir.home(user_name = nil) → dirpath

Returns the home directory path of the user specified with user_name if it is not nil, or the current login user:

Example
Dir.home         # => "/home/me"
Dir.home('root') # => "/root"

Raises ArgumentError if user_name is not a user name.

See also .glob .mkdir .getwd .mktmpdir also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0