Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

directories_next provides different output to dirs_next when %USERPROFILE% is changed #57

Open
CLIDragon opened this issue Jan 27, 2022 · 0 comments

Comments

@CLIDragon
Copy link

CLIDragon commented Jan 27, 2022

This issue came up while I was debugging an issue over on starship/starship#3526. When %USERPROFILE% is set to a non-null, invalid home directory, directories_next, but not dirs_next, fails to provide the correct home directory. This behaviour is consistent across dirs, dirs_next, directories and directories_next. What's strange is that directories and directories_next succeed when %USERPROFILE% is set to null, or a valid home directory that does not belong to the user (such as C:\Users\Default). They also seem to succeed when I set USERPROFILE using std::env::set_var, which is truly strange.

Here is the script I used to test the behaviour of dirs_next, directories_next, etc.

fn main() {
    let home_dir = directories_next::BaseDirs::new().map(|base_dirs| base_dirs.home_dir().to_owned());
    println!("Home directory (next): {:#?}", home_dir);

    let home_dir = dirs_next::home_dir();
    println!("Home dir (next): {:#?}", home_dir);

    let home_dir = directories::BaseDirs::new().map(|base_dirs| base_dirs.home_dir().to_owned());
    println!("Home directory: {:#?}", home_dir);

    let home_dir = dirs::home_dir();
    println!("Home dir: {:#?}", home_dir);
}

cargo.toml

[dependencies]
directories = "4.0.1"
directories-next = "2.0.0"
dirs = "4.0.0"
dirs-next = "2.0.0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant