std::fs::create_dir_all fails on path ending with . if it does not already exist
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
std::fs::create_dir_all("/tmp/foo/.").unwrap();
I expected to see this happen: /tmp/foo is created
Instead, this happened:
Err(Os { code: 2, kind: NotFound, message: "No such file or directory" })
If the path already exists, the call succeeds without errors.
See this play for a demo:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=b93fae57ba5820c2bfeb70e7808a0ab9
Meta
Checked on both stable and nightly on play.rust-lang.org
Backtrace
thread 'main' (14) panicked at src/main.rs:4:62:
called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
stack backtrace:
0: __rustc::rust_begin_unwind
at /rustc/2e2b193f8ada105f27608b7be81c293e0d7292cb/library/std/src/panicking.rs:676:5
1: core::panicking::panic_fmt
at /rustc/2e2b193f8ada105f27608b7be81c293e0d7292cb/library/core/src/panicking.rs:80:14
2: core::result::unwrap_failed
at /rustc/2e2b193f8ada105f27608b7be81c293e0d7292cb/library/core/src/result.rs:1870:5
3: <core::result::Result<(), core::io::error::Error>>::unwrap
at ./.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:1232:23
4: playground::main
at ./src/main.rs:4:62
5: <fn() as core::ops::function::FnOnce<()>>::call_once
at ./.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided Rust reproducer for std::fs::create_dir_all("/tmp/foo/.") on stable and nightly, then trace the filesystem entry point involved. Done means the call creates the missing /tmp/foo directory and succeeds when the path ends with a dot, with coverage for the reported case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100