Implement std::fs::canonicalize for WASI
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
std::fs::canonicalize() is not implemented for WASI, but I can't see any show-stopping reason why it couldn't be (maybe pre-opens complicate it?). I ran into this when attempting to compile rustfmt for WASI.
I found a couple of related issues:
1
#82339 - suggests using the Prefix part of paths (like C:) for pre-opens.
@RReverser said
Another reason I'm asking is that I want to implement Path::canonicalize on WASI because it frequently comes up during cross-compilation, and then fails at runtime - turns out, a lot of crates use it to translate relative paths to absolute ones.
This is exactly the situation I ran into. I'll also note that this was quite annoying to debug since the error message in its entirety was operation not supported on this platform, you can't use RUST_BACKTRACE, rustfmt doesn't have extensive logging, and I don't fancy setting up WASM debugging. I resorted to tedious printf debugging. (Side rant: for all the emphasis Rust puts on compiler error messages its runtime error messages are usually quite terrible!)
2
This issue in Rollup where they ran into the same problem and have a simple implementation we could maybe use.
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 locating the WASI implementation of std::fs::canonicalize and read the related pre-open discussion in issue #82339. Compare the simple implementation linked from the Rollup issue, then verify that canonicalize works on WASI and addresses the rustfmt failure described here.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, wasm
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100