`file!()` returns incorrect `Path`s on WASM target built on Windows.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Here is a minimal reproducible example: https://github.com/andriyDev/wasm-path-error
The file!() macro produces nonsensical paths for WASM built on Windows.
On Windows, file!() in src/lib.rs produces src\\lib.rs with the components ["src", "lib.rs"].
I would expect file!() to produce the same set of components on WASM. However, on WASM built on Windows, file!() in src/lib.rs produces src\\lib.rs with the components ["src\\lib.rs"].
It seems that the path is not translated appropriately from Windows to WASM.
Meta
rustc --version --verbose:
rustc 1.85.0 (4d91de4e4 2025-02-17)
binary: rustc
commit-hash: 4d91de4e48198da2e33413efdcd9cd2cc0c46688
commit-date: 2025-02-17
host: x86_64-pc-windows-msvc
release: 1.85.0
LLVM version: 19.1.7
Additional Context
This is relevant for https://github.com/bevyengine/bevy/issues/14246. We are using the file path to refer to an asset in the src directory, but due to the incorrect components, we can't remove the src prefix.
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 with the linked minimal reproduction and run the file!() case from src/lib.rs on a Windows-built WASM target, comparing its path components with the native result. Trace the file!() macro's handling of the emitted path across the Windows-to-WASM boundary. Done means the WASM result has separate src and lib.rs components, matching the expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, wasm
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100