Assertion fails when passing `C:` as command line argument
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 65/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- rust
- Domain
- cli, operating-systems
Research direction
Start with the failing assertion in src/path.rs:12 and trace how src/bin/edit/main.rs handles the C: argument around handle_args. Reproduce the issue with cargo run -- C: on Windows, then verify that the command opens successfully with an untitled buffer without panicking.
Written by the indexing model from the issue text.
Description
Repro
Run the following command in this repository:
cargo run -- C:
Expected result
Edit opens successfully with an untitled buffer.
Actual result
Crashes with the following assertion error:
thread 'main' panicked at src\path.rs:12:5:
assertion failed: path.is_absolute()
stack backtrace:
0: std::panicking::begin_panic_handler
at /rustc/2805e1dc4c18ed4c84d161502c48da870c56f68a/library\std\src\panicking.rs:697
1: core::panicking::panic_fmt
at /rustc/2805e1dc4c18ed4c84d161502c48da870c56f68a/library\core\src\panicking.rs:75
2: core::panicking::panic
at /rustc/2805e1dc4c18ed4c84d161502c48da870c56f68a/library\core\src\panicking.rs:145
3: edit::path::normalize
at .\src\path.rs:12
4: edit::handle_args
at .\src\bin\edit\main.rs:253
5: edit::run
at .\src\bin\edit\main.rs:74
6: edit::main
at .\src\bin\edit\main.rs:56
7: core::ops::function::FnOnce::call_once<std::process::ExitCode (*)(),tuple$<> >
at /rustc/2805e1dc4c18ed4c84d161502c48da870c56f68a\library\core\src\ops\function.rs:250
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Explanation
On Windows a drive letter path like C: is special. It is a relative path and it means the current working directory of the drive. If my understanding is correct, on Windows each drive has its current working directory.
This means
Path::new("C:").is_absolute()
returns false but
Path::new("C:\\foo").join("C:")
returns C:. This behavior causes the crash.
- Dominant language
- Rust
- Stars
- 14.6k
- Forks
- 735
- Avg merge
- 8h 40m
- Merged PRs (30d)
- 4
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.
More from microsoft/edit
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
-
Difficulty 3/5 1-2 days Newbie friendliness 75/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
bitcoindevkit/bdk-ffi#1125 ·