Skip to content

Commit fd77410

Browse files
tclementdevjhheider
authored andcommitted
Use SUDO_HOME environment variable to derive the pkgx directory if it is set. Without this, we might work on the root user directory (as seen on Linux).
1 parent 1c8dfdb commit fd77410

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

crates/lib/src/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ fn get_pkgx_dir() -> io::Result<PathBuf> {
6969
}
7070
}
7171

72+
// Use sudoer home directory if it is set.
73+
if let Ok(path) = env::var("SUDO_HOME") {
74+
let path = PathBuf::from(path).join(".pkgx");
75+
if path.is_absolute() {
76+
return Ok(path);
77+
}
78+
}
79+
7280
let default = dirs_next::home_dir().map(|x| x.join(".pkgx"));
7381

7482
if default.clone().is_some_and(|x| x.exists()) {

0 commit comments

Comments
 (0)