### Function

# GLib get_home_dir

since: 2.0

#### Declaration

    const gchar*
    g_get_home_dir (
      void
    )

#### Description

Gets the current user’s home directory.

As with most UNIX tools, this function will return the value of the `HOME` environment variable if it is set to an existing absolute path name, falling back to the `passwd` file in the case that it is unset.

If the path given in `HOME` is non-absolute, does not exist, or is not a directory, the result is undefined.

Before version 2.36 this function would ignore the `HOME` environment variable, taking the value from the `passwd` database instead. This was changed to increase the compatibility of GLib with other programs (and the XDG basedir specification) and to increase testability of programs based on GLib (by making it easier to run them from test frameworks).

If your program has a strong requirement for either the new or the old behaviour (and if you don’t wish to increase your GLib dependency to ensure that the new behaviour is in effect) then you should either directly check the `HOME` environment variable yourself or unset it before calling any functions in GLib.

Available since: 2.0

#### Return value

Type: `const gchar*`

The current user’s home directory.

The data is owned by the called function.
The value is a file system path, using the OS encoding.