Skip to content

Commit e7481a4

Browse files
committed
fix: replace deprecated env::home_dir() with env::var("HOME")
The env::home_dir() function is deprecated since Rust 1.29. Replace it with env::var("HOME") which is the consistent approach used elsewhere in the codebase. Added a clarifying comment about why user desktop files are conditionally included.
1 parent 967a7f8 commit e7481a4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/backends/distrobox/distrobox.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ impl DesktopFiles {
8989

9090
fn into_map(self) -> BTreeMap<PathBuf, String> {
9191
let mut desktop_files = self.system;
92-
if env::home_dir() != Some(self.home_dir) {
92+
// Only include user desktop files if the container's home directory is different from the host's
93+
// This avoids showing duplicate entries when the container shares the host's home directory
94+
let host_home = env::var("HOME").ok().map(PathBuf::from);
95+
if host_home.as_ref() != Some(&self.home_dir) {
9396
desktop_files.extend(self.user)
9497
}
9598
desktop_files

0 commit comments

Comments
 (0)