-
Notifications
You must be signed in to change notification settings - Fork 13.3k
file!()
returns incorrect Path
s on WASM target built on Windows.
#140883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The precise meaning of I see that the relevant Bevy code does some runtime (in-Wasm) processing of |
We do this for embedded assets. Embedded assets use Essentially the How can we manipulate the path on the host code? The only way I know of would be a proc_macro but that seems very heavyweight for what we need. Alternatively, if we could know the host machine, we could apply the fix specifically for Windows host + non-Windows target. If we do this now, we can only conditionally compile based on the target which means preventing use of Edit: I've totally confused myself. |
Ah, I see, I jumped to the conclusion that since the macro expands to runtime path manipulation code, it must be also loading the files based on the computed paths. If you're delegating the file loading to
You could add a build script to the crate that defines this macro (if it doesn't have one already) and have set a |
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!()
insrc/lib.rs
producessrc\\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!()
insrc/lib.rs
producessrc\\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
:Additional Context
This is relevant for bevyengine/bevy#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 thesrc
prefix.The text was updated successfully, but these errors were encountered: