File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -617,7 +617,7 @@ impl Error for JoinPathsError {
617617/// # Unix
618618///
619619/// - Returns the value of the 'HOME' environment variable if it is set
620- /// (including to an empty string).
620+ /// (and not an empty string).
621621/// - Otherwise, it tries to determine the home directory by invoking the `getpwuid_r` function
622622/// using the UID of the current user. An empty home directory field returned from the
623623/// `getpwuid_r` function is considered to be a valid value.
Original file line number Diff line number Diff line change @@ -633,7 +633,10 @@ pub fn temp_dir() -> PathBuf {
633633}
634634
635635pub fn home_dir ( ) -> Option < PathBuf > {
636- return crate :: env:: var_os ( "HOME" ) . or_else ( || unsafe { fallback ( ) } ) . map ( PathBuf :: from) ;
636+ return crate :: env:: var_os ( "HOME" )
637+ . filter ( |s| !s. is_empty ( ) )
638+ . or_else ( || unsafe { fallback ( ) } )
639+ . map ( PathBuf :: from) ;
637640
638641 #[ cfg( any(
639642 target_os = "android" ,
You can’t perform that action at this time.
0 commit comments