rust-lang / rust-lang/rust

fs::create_dir_all doesn't work on other computers

Open
#120,054 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-filesystem A-io O-windows S-needs-repro T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Hi everyone, sorry for my bad english

I have this code:


// Here there is a path generation algorithm, i've excluded it because on the two computers the generated path are the same

//The generated path
let new_file_path = "Z:\NUOVO RAPPORTINO ELETTRONICO\2024\1 Gennaio\Name Surname";

match std::fs::create_dir_all(new_file_path) {
    Ok(_r) => {
    
        println!("Creazione cartelle avvenuta con successo!");
        
        //Other things to do if succeeds
      
    },
  
    Err(error) => {
        println!("Errore durante la creazione delle cartelle: {error}");
        println!("GetLastError: {}", unsafe { GetLastError().to_string() });
    },

}

that runs fine on my computer, but throws a runtime error on another.

On the other computer, std::fs::create_dir_all throws this error: failed to create whole tree
and winapi's GetLastError() gives me: ERROR_PATH_NOT_FOUND

The OSs are not the same, mine is Windows 10, the other one is Windows 11, but i don't think that's the problem.

I've compiled it with cargo build --release

Z:\ is a shared network folder on a third computer (Windows 11), but both computer one and two have same permissions

The path Z:\NUOVO RAPPORTINO ELETTRONICO\2024 already exist, on my computer it generates \1 Gennaio\Name Surname in it and then proceed with the other code, on the other one it throws the same errors both if the path "fully" exists (doesn't need to create any folder) or if it needs to create it.

Does anyone have any clue on what's going on?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with std::fs::create_dir_all and compare its behavior on the two Windows systems using the shown Z:\ network path. Check the mapped drive, existing directory, permissions, and GetLastError result in each environment. Done means identifying a reproducible cause or confirming a Rust issue with a minimal reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.