2 unstable releases

0.2.1 Aug 27, 2023
0.1.0 Aug 13, 2023

#317 in Configuration

Download history 29/week @ 2023-08-13 8/week @ 2023-08-20 29/week @ 2023-08-27 7/week @ 2023-09-03 19/week @ 2023-09-10 9/week @ 2023-09-17 41/week @ 2023-09-24 2/week @ 2023-10-01 20/week @ 2023-10-08 22/week @ 2023-10-15 31/week @ 2023-10-22 60/week @ 2023-10-29 43/week @ 2023-11-05 65/week @ 2023-11-12

204 downloads per month
Used in archie-cli


262 lines


This crate exists to provide a portable method to getting any user's home directory. The API is rather simple: there are two main functions, get_home and get_my_home. The former can get the home directory of any user provided you have their username. The latter can get the home directory of the user executing this process.

This crate aims to work on both Windows and Unix systems. However, Unix systems do not have a unified API. This crate may not work on Unix systems which do not have the getpwnam_r(3), getpwuid_r(3), and getuid(2) functions.


This crate is on crates.io and can be used by executing cargo add homedir or adding the following to the dependencies in your Cargo.toml file.

homedir = "0.2.1"


Get the process' user's home directory.

use homedir::get_my_home;

// This assumes that the process' user has "/home/jpetersen" as home directory.

Get an arbitrary user's home directory.

use homedir::get_home;

// This assumes there is a user named `Administrator` which has
// `C:\Users\Administrator` as a home directory.

The full documentation of the crate is available on the docs.rs page.


Licensed under either of

at your option.


Unless you explicitely state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Feel free to put a copyright header in your name in any files you contribute to.

Copyright (C) 2023 James Petersen m@jamespetersen.ca.


~484K SLoC